Thursday, August 18, 2016

Using the FxCop Build Runner in Jetbrains TeamCity

If you want to use the FxCop Build Runner in Jetbrains TeamCity, you can consult the documentation here: https://confluence.jetbrains.com/display/TCD10/FxCop



For the path to FxCop, using the option for "Autodetect installation" should work well for you in most cases:



In some cases, if you have multiple versions of Visual Studio installed on your machine, you may want to select a specific version of FxCop:




  • For Visual Studio 2013, you will select 12.0
  • For Visual Studio 2015, you will select 15.0
For the list of Assemblies, you can specify a relative path to the assemblies by using a wildcard expression such as *.dll.  Of course, since you are probably compiling a solution with multiple projects, you will want to specify the path to each set of assemblies in your solution such as MyProject\bin\MyProject.dll, MyProject2\bin\MyProject2.dll as follows:






You need to make sure that the names of your assemblies are all SPACE SEPARATED in order to ensure that FxCop runs correctly against them.

You must then configure the Advanced Options for FxCop in order to be able to run correctly against referenced assemblies etc.:


I like to specify the path to "Search referenced assemblies in directories" and uncheck the option for "Search referenced assemblies in GAC".  This is especially relevant since I distribute most of my assembly references through NuGet packages rather than installing them into the GAC.

Optionally, you can also configure the "Build Failure Conditions" such that any "Fail on analysis errors" in FxCop will also trigger a failure of the build

Personally, I avoid this setting since I generally work with offshore development teams which do not run regular code analysis on their projects/solution nor may they be licensed to run Code Analysis on their solution with their edition of Visual Studio.  Visual Studio 2015 Professional and above now offers Code Analysis and Code Metrics, but earlier editions of Visual Studio such as Visual Studio 2013 did not.  However, setting this value can potentially be disruptive to any team which is not very particular about following all of the guidelines outlined by FxCop.

Finally, once you have specified the correct path for your build, you will be able to use the TeamCity FxCop Build Runner to generate a Code Inspection report!

You can access the Code Inspection report from the "Build shortcuts" dropdown menu:









No comments:

Post a Comment