Run Roslyn Code Analyzers on Build Server

2020-07-09 10:09发布

问题:

I'm trying to create custom static analysis rules against my code base such that compiler errors will be generated if a developer fails to follow my companies coding convention. It seems with Visual Studio 2015, Roslyn Code Analyzers are the way to accomplish this.

The MSDN articles I've read indicate Code Analyzers are packaged up as NuGet or VSIX packages. That's great for adding red squiggles in Visual Studio, but I want to make sure the compiler errors are also generated on my Jenkins build server.

Are Roslyn Code Analyzers run as part of the MSBuild pipeline in such a way that they will generate compiler errors on my build server? Do I need to setup MSBuild in anyway?

回答1:

Yes; Analyzers are integrated with MSBuild.

Analyzer References in Visual Studio are part of the project file, and the Roslyn MSBuild task will pass the to the compiler.

You don't need to do anything.