Let Build Fail if there are FXCop or StyleCop errors

Hi

is there a way to let a build fail if there are fxcop or stylecop violations (so not when there is only one general warning?)

Hi Haggy,

Assuming you are using an MSBuild action, you can add the following under a PropertyGroup in your csproj file.

<CodeAnalysisTreatWarningsAsErrors>trueCodeAnalysisTreatWarningsAsErrors>
<RunCodeAnalysis>trueRunCodeAnalysis>

Use the following to treat general compiler warnings as errors: 

<TreatWarningsAsErrors>trueTreatWarningsAsErrors>

See this article for further details


thx for your reply. is there also a possibility for stylecop?

Hi Haggy,

You can add this:

<StyleCopTreatErrorsAsWarnings>falseStyleCopTreatErrorsAsWarnings>

Have have look at this article for further details