I recently started using Code Analysis on my projects in Visual Studio. I have created a custom ruleset to use with all of my projects that include two of the Microsoft defined rulesets. I've been working to integrate FxCop into the CI build process to fail builds that don't pass all rules. What's really odd to me is that I can't use my ruleset to define what rules FxCop scans the code against. How do I make it so Visual Studio's Code Analysis rules match up to FxCop's rules?
You already have a rule set file that I assume you have figured out how to integrate in your projects and utilize through Visual Studio.
You can use this same rule set file in FxCopCmd.exe
:
FxCopCmd.exe /out:Violations.xml /ruleset:=Custom.ruleset /file:MyAssembly.dll
I have done this using Jenkins and it works just fine. Run FxCopCmd.exe
with no arguments and you should see descriptions for all available command-line switches.
For our CI build we have a special build configuration (in addition to standard Debug and Release) which includes running code analysis ("RunCodeAnalysis" MSBuild task as i remember) and option "Treat warning as error". So the build fails if we have an FxCop error and it uses the same rule set as VS. This way you don't need to use FxCopCmd and can share rulesets. But you have to manually add this build configuration to every project of your solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With