5

I have two build steps in my build configuration: Visual Studio (sln) build runner, followed by an FxCop build runner. I'm using TeamCity 6.0.1 and FxCop 10.0.

Out of the box, the FxCop runner in TeamCity seems to only report on rule violations, and produces a report on a Code Inspection tab. I want to ensure that if any violation occurs that the build step fails and thus causes an entire build failure.

Is there a way to accomplish this?

Llyle
  • 5,980
  • 6
  • 39
  • 56

2 Answers2

2

Please set the Errors limit property in your FxCop build step configuration to 0. This should break the build if there is at least one analysis error.

Furthermore, there is a similar Warnings limit property. If you don't want to allow any rule violation at warning level, insert in this field also the value 0. If you want to allow rule violations where the rule attribute BreaksBuild == False, leave this property empty.

I've tried that using TeamCity 6.0 (build 15772) and FxCop 10.0.

[14:39:22]: [Step 2/2] Importing inspection results
[14:39:22]: [Step 2/2] Errors limit reached: found 8 errors, limit 0
[14:39:22]: [Step 2/2] ##teamcity[buildStatus status='FAILURE' text='Errors: 8, warnings: 1']
Llyle
  • 5,980
  • 6
  • 39
  • 56
KimCM
  • 1,411
  • 11
  • 14
  • In my experience the "Fail on analysis errors" flag only ensures that if FxCop has a load error, such as failing to load a referenced assembly, then the build step causes a build failure. The flag doesn't cause a build failure when a rule is violated. – Llyle Apr 26 '11 at 20:26
  • Sorry, you're right. The "Fail on analysis errors" flag is not what you are looking for. I try to give a better answer. – KimCM Apr 27 '11 at 12:39
  • I've been running FxCop through the MSBuild runner. Using some XPath you can query the results XML file and choose whether to break it accordingly. See http://www.ademiller.com/blogs/tech/2009/06/making-sure-fxcop-warnings-and-errors-break-the-build/ for the report parsing. See http://confluence.jetbrains.net/display/TCD65/Build+Script+Interaction+with+TeamCity for service messages in TeamCity. – Colin Bowern Feb 21 '12 at 05:24
0

In the version 7.0 EAP it is special "Build fail condition" in Build Configuration=>Build Failure conditions=>Add build failure condirion, e.g. "Fail build if number of inspection errors is more than 30"

Pashec
  • 23,199
  • 3
  • 26
  • 26
  • That sounds quite promising, and it would be a feature I'd be using often on my more advanced build configurations. – Llyle Jan 25 '12 at 20:05