I have a .NET solution containing several C# 6.0 projects. Every project references the StyleCop Analyzer via NuGet. Within Visual Studio, I have the possibility to distinguish between building and analyzing the code, but I don't see how to do this with MSBuild v14.0 on the command line (e. g. on a CI server). I'm calling msbuild mySolution.sln /t:Rebuild
with the following options, none of them worked:
/p:RunCodeAnalysis=False
/p:RunCodeAnalysisOnThisProject=False
/p:RunCodeAnalysis=False,RunCodeAnalysisOnThisProject=False
Whatever I do, the warnings SAxxxx remain in the output. Does anyone know how to disable code analysis when using MSBuild?
Background: on our CI server, I want to distinguish between "basic MSBuild warnings" and warnings coming from static code analysis.
Regards
In
.Net 5
supported project you can simply edit the.csproj
and add:<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
Disable code analysis on build<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
Disable code analysis on live analysis<RunAnalyzers>false</RunAnalyzers>
prevent analyzers from running on this projectI use it in my Unit Testing Projects by adding it in the
PropertyGroup
that holds theTargetFramework
like so:for further details refer to MS Documentation