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
- http://blog.tatham.oddie.com.au/2010/01/06/custom-code-analysis-rules-in-vs2010-and-how-to-make-them-run-in-fxcop-and-vs2008-too/
- http://blogs.msdn.com/b/codeanalysis/archive/2010/03/26/how-to-write-custom-static-code-analysis-rules-and-integrate-them-into-visual-studio-2010.aspx
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.
No comments:
Post a Comment