There's not much to put here at the moment, so here's a simple tip on how to get individual, actionable warnings from FxCop when you build in Visual Studio, and force the build to fail if any warnings actually occur. Just insert the following block into your MSBuild project file:

  <PropertyGroup>
    <FxCopResults>$(ProjectDir)obj\$(Configuration)\FxCopResults.xml</FxCopResults>
    <PostBuildEvent>"%25ProgramFiles%25\Microsoft FxCop 1.36\FxCopCmd.exe" /file:"$(TargetPath)" /console /out:"$(ProjectDir)obj\$(ConfigurationName)\FxCopResults.xml"</PostBuildEvent>
  </PropertyGroup>
  <Target Name="BeforeBuild">
    <Delete Files="$(FxCopResults)" ContinueOnError="true" />
  </Target>
  <Target Name="AfterBuild">
    <Error Text="One or more FxCop warnings occurred." Condition="Exists('$(FxCopResults)')" />
  </Target>

For more information about how this works, take a look at the explanation on my blog.


You may also want to check out the rest of my blog's entries about software development.

Gavin's mugshot (2009)