0

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?

Nanhydrin
  • 4,332
  • 2
  • 38
  • 51
Felipe
  • 17
  • 3
  • You want to treat warnings as errors? The parameter you've provided looks like it does the opposite. Maybe try `/p:TreatWarningsAsErrors = true` – Nanhydrin Feb 06 '19 at 13:52
  • Thanks, I've added that parameter but MSBuild task continues avoiding it, and compiles with no error. – Felipe Feb 06 '19 at 17:23

1 Answers1

0

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

Shamrai Aleksander
  • 13,096
  • 3
  • 24
  • 31