-->

Calling Roslyn Analyzers from command line

2019-07-18 11:23发布

问题:

Using Roslyn Analyzers while developing in Visual Studio 2015 is great. However, it would be even greater to be able to call analyzers from a pre-commit hook or a CI like TeamCity in order to make sure non-conformant code is flagged.

Is there any way to get the results of an analyzer by calling a command line utility or will this need to be custom made?

回答1:

Roslyn Analyzers can be ran by csc.exe or vbc.exe (the compilers themselves), so just invoke the compiler. Assuming your Continuous Integration is already building, and your analyzers are added to the project file or to a NuGet package, this should Already Be Working™.