This blog has moved to Medium

Subscribe via email


MSBuild FxCopSolution Task

Objective – Automatically run FxCop on our solution

Possible solution – existing FxCop Community Task

Problems with solution:

  1. Only compatible with FxCop 1.32 (hard coded folder path!!!)
  2. Accepts only DLLs as input, not a solution (our solution doesn’t have a single output directory, so the DLLs are scattered)

Solution – writing a custom task called FxCopSolution and tweaking the FxCop task.

For now, I couldn’t get a hold of the lead developer, this is not checked in to the main repository in Tigris. The source code and binaries should be in this zip file.

This zip contains:

  1. Source – The source for the FxCopSolution task
    1. Unfortunately the unit tests are not very useful, beacuse it’s currently impossible to actually run the task from inside the tes.
    2. I included some 3rd party libraries not included in the original MSBuild release, that were needed to compile it (before my changes).
    3. I had to comment out the Source Safe tasks – they required a lib I didn’t find.
  2. Bin – Everything needed to deploy the task
    1. Sample.MSBuild.proj – a sample MSBuild project that uses the task
    2. Build/MSBuildCommunityTasks – a folder containing the binaries
    3. Build/fxcop-summary.xsl – an XSL I found somewhere that translates the output from FxCop to a displayable HTML. It’s not that pretty (suggestions are welcome), but it does the job.

We integrated the task with TeamCity (simply adding another MSBuild build and specifying as artifact Build/Output.html), and now our build displays a huge number of FxCop errors we’ll fix in the following weeks.

If you have any errors using the zip (there are bound to be a few silly ones) and/or questions, feel free to contact me at ron.gross@gmail.com.