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.
- Right click on the project property and go to the “Code Analysis” tab
- Select check box “Enable Code Analysis on build”
- Select “
from “Run this rule set” dropdown and select your custom rule set you created or available with you.
- Click “Open” to customize
- Select/Unselect Rules using check box
- Set the Action likes if rules violate by code then it should be warning, error or none
- “Save” the rule set
- “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.