Run code analysis rule set with FxCop 10 GUI
I'm u开发者_JAVA百科sing code analysis in .NET 4, where I have a custom rule set included in the project file for my project.
I would like to run FxCop 10 GUI on the project output, using the same rules as in the custom rule set.
Is this possible with FxCop GUI (FxCop.exe)?
The FxCop 10 GUI application does not include any support for rulesets. The closest you could get with the GUI app would probably be to automate generating the contents of the Rules node of a .fxcop project file from a ruleset before loading the project in FxCop. If you decide to do this, there are APIs in the FxCop/Code Analysis assemblies that could help a bit (e.g.: Microsoft.VisualStudio.CodeAnalysis.RuleSets.RuleSet.LoadFromFile).
I had the same problem and although FXCop does not support rulesets you can use an undocumented commandline switch from the FXCopCmd.exe. Simply define the /rid switch for the messages you want to suppress. This switch can occure multiple times. e.g:
"$(ProgramFiles)\Microsoft FxCop 10.0\FxCopCmd.exe" /console /file:"$(TargetPath)" /rid:-Microsoft.Design#CA1005 /rid:-Microsoft.Design#CA1020
in the post build event of your VS 2008 project.
Hth Uli
精彩评论