6

What is the best way to run and report Visual Studio 2012 code analysis in TeamCity?

haymansfield
  • 5,419
  • 4
  • 34
  • 51

2 Answers2

5

Since FxCop or Code Analysis integrates directly into MsBuild, it's probably as simple as adding /p:RunCodeAnalysis=Always or /p:RunCodeAnalysis=True to the MsBuild commandline when building the project. Since this will generate standard compiler warnings, TeamCity should pick them up automatically.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • I would like to upvote this 10 times! I lost a few hours trying it by difficult ways until I found your answer. I just put the parameter on my first build step (MsBuild) and created a new "Failure Condition" finding by specific text in build log. Very thank you! – fabriciorissetto Jul 15 '15 at 00:26
0

Visual Studio 2010+ Code Analysis is (based on) FxCop 10.0. You can simply add a 'FxCop' build runner type build step.

When the 'Report XSLT file' setting is configured the build runner will output a HTML report. FxCop 10.0 includes a default XSLT file under '%system.FxCopRoot%/Xml/FxCopReport.xsl' to generate a default HTML report.

Marco G
  • 703
  • 6
  • 18