Skip to content
Jun 11 2008

Save FxCop Messages to XML Report Only

Or in other words, how to make FxCop *not* fail your builds…

I’ve been spending a lot of time lately improving our build processes, part of which includes adding FxCop to our main trunk builds. I’ve added FxCop into the build process on just about every project I’ve worked on the last 4 years, but there’s always been a problem:

  • Every now and then an exception would occur in the build because FxCop tried to save the messages back into the .fxcop project file but couldn’t, mainly because the .fxcop file is under source control and is read-only.

I love FxCop, but this issue has always forced me to remove FxCop from the builds because as great as FxCop is, it should *never* be the cause of a broken build. It’s never been a huge deal because I run FxCop manually all the time anyway, but it’s something I’ve never been able to workaround. Until now.

You see, all FxCop projects (those .fxcop files) have their own options, separate from the settings of FxCop itself (Project > Options). I’ve looked at those project options many times before but for some reason I never paid close enough attention to the Save Messages section, shown below with the defaults:

FxCopProjectOptionsDefault

What those options are saying is to save the messages into both the project file and the output file that contains the XML for the report. But that’s not what we want. We only want the messages saved to the XML output file, not the project file:

FxCopProjectOptions

Like I said earlier, I don’t know how I overlooked those particular checkboxes before, but setting them so that the messages are only saved to the XML report solved the problem. And now I’ll never have to remove FxCop from a build process again. Happy days.

Similar Posts:

  • http://danhounshell.com/ Dan Hounshell

    Great tip. I’ve struggled with that exact thing in the past.