Msbuild warning does not break the build

225 Views Asked by At

After execute MSbuild task (under TFS2017) with the following parameters:

/m /property:StyleCopTreatErrorsAsWarnings=false /property:StyleCopEnabled=true /p:SkipInvalidConfigurations=true

the compilation succeed. The warning is shown under Summary / build but my expectation is that the compilation would have to finish with error.

The warning is:

Warning : CA1822 : Microsoft.Performance : The 'this' parameter (or 'Me' in Visual Basic) of ...

Are the MsBuild parameters set incorrectly?

1

There are 1 best solutions below

0
Shamrai Aleksander On

By default all rules for code analysis - warnings. You have to set for critical rules an error property:

  1. Select code analysis:

enter image description here

  1. Update the rule properties:

enter image description here

  1. That`ll generate a new ruleset file to your project

enter image description here

  1. You get a failed build

enter image description here

Also you may create any custom ruleset and use it for your builds: How do I specify a ruleset from MSBuild