FxCop and Code Analysis Rules

I recently started using Code Analysis for my projects in Visual Studio. I created a special set of rules for use with all my projects, which include two sets of rules defined by Microsoft. I worked on integrating FxCop into the CI build process so that builds fail that do not pass all the rules. What is really strange to me is that I cannot use my set of rules to determine which rules FxCop scans with code. How to do this so that Visual Studio code analysis rules comply with FxCop rules?

+7
source share
2 answers

You already have a rule set file, which I assume you figured out how to integrate into your projects and use through Visual Studio.

You can use the same rule set file in FxCopCmd.exe :

 FxCopCmd.exe /out:Violations.xml /ruleset:=Custom.ruleset /file:MyAssembly.dll 

I did this with Jenkins and everything works fine. Run FxCopCmd.exe with no arguments and you will see descriptions for all available command line switches.

+8
source

For our CI assembly, we have a special assembly configuration (in addition to the standard Debug and Release), which includes analysis of the execution code (MSBuild "RunCodeAnalysis" task, as I recall) and the option "Treat warning as an error." Thus, the assembly fails if we have an FxCop error and it uses the same rule as VS. Thus, you do not need to use FxCopCmd and share rule sets. But you must manually add this build configuration to each project in your solution.

+3
source

All Articles