Thursday, December 13, 2012

How to enable code analysis for Visual Studio 2010 projects (FxCop, StyleCop etc.)

Below I am giving steps to enable FxCop rule set. To enable FxCop Rule set into your projects, first you need the FxCop rule sets files (*.ruleset). By default you will get most of sets from Microsoft when you install Visual Studio 2010, you can customize those by selecting or unselecting rule sets. Or if you want to create your own custom rule set then below link will guide you for this 
I am assuming that rule set are available with you and you want to enable FxCop/StyleCop/etc. for your project.
  1. Right click on the project property and go to the “Code Analysis” tab
  2. Select check box “Enable Code Analysis on build”
  3. Select “ from “Run this rule set” dropdown and select your custom rule set you created or available with you.
  4. Click “Open” to customize
  5. Select/Unselect Rules using check box
  6. Set the Action likes if rules violate by code then it should be warning, error or none
  7. “Save” the rule set
  8. “Save” the Project
 


FxCop rule set is now enable for this project, when you build your project each time all rules run and give you errors/warning  if code violate the rules.

No comments: