Jane Dallaway

Jane Dallaway

Jane Dallaway  //  Data loving developer/leader/product shaper, storyline curator/creator, life-long learner, photographer, dog owner, reader, crafter, gardener and occasional snowboarder

This blog contains all sorts of odds and ends, from event reviews, stuff about my storyline project, bits of craft, through thoughts on learning, to photography stuff, and general inspiration things. It's a bit all over the place with no real theme, but then so am I!

Email: jane @ dallaway.com
Also at:    

Integrating FXCop into Visual Studio 2008

I was using the FXCopAddin for VS2005 but I couldn't get it to work for VS2008. The FXCopAddin didn't seem to have been updated for quite some time, and so I didn't have high hopes of it becoming compatible anytime soon. I really liked the integration that the AddIn gave me, the fact that my warnings were shown in the standard VS error window etc, so I wanted to find a similar, alternative solution.

I started with working out the command line version of what I was trying to do -
"C:\Program Files\Microsoft FxCop 1.36\FxCopCmd.exe" /c /f:"C:\Working\MyTestApp.exe" /r:"C:\Program Files\Microsoft FxCop 1.36\Rules" /consolexsl:"C:\Program Files\Microsoft FxCop 1.36\Xml\VSConsoleOutput.xsl"

Which is, basically, call FXCop (version 1.36) using the Rules dlls specified in "C:\Program Files\Microsoft FxCop 1.36\Rules", and use the XSL file in "C:\Program Files\Microsoft FxCop 1.36\Xml\VSConsoleOutput.xsl" to formulate the output.

Moving on from this, I put this working command line into the Post-build event command line as:
"C:\Program Files\Microsoft FxCop 1.36\FxCopCmd.exe" /c /f:"$(TargetPath)" /r:"C:\Program Files\Microsoft FxCop 1.36\Rules" /consolexsl:"C:\Program Files\Microsoft FxCop 1.36\Xml\VSConsoleOutput.xsl"

Where $(TargetPath) gets equated to the generated dll/exe etc in the build process.

Media_httpfarm4static_hvjab

Behind the scenes, this gets recorded in the .csproj file as:
<PropertyGroup>
  <PostBuildEvent>"C:\Program Files\Microsoft FxCop 1.36\FxCopCmd.exe" /c /f:"$(TargetPath)" /r:"C:\Program Files\Microsoft FxCop 1.36\Rules" /consolexsl:"C:\Program Files\Microsoft FxCop 1.36\Xml\VSConsoleOutput.xsl"</PostBuildEvent>
</PropertyGroup>

Media_httpfarm3static_xwsgo

And bingo, the errors get reported into the warnings window. From here they are clickable etc.

0 comments

Leave a comment...