I\'ve been doing research on how to enable source analysis for the project I\'m working on and plan to use StyleCop. The setup I have is a TFS Server for source control, usi
Some points for using StyleCop in general:
Then simply add the relative reference to your project files, like this (I left out < and >):
Import Project="..\..\lib\Microsoft StyleCop\Microsoft.StyleCop.Targets"
We treat all StyleCop warnings as errors using the StyleCopTreatErrorsAsWarnings
setting in the project file.
Settings.StyleCop
) in the root directory where your VS solution is (and of course place it under the source control). StyleCop knows how to find this file automatically (by loooking up the directory tree). This way you can have custom settings for each solution.This way StyleCop will be integrated in your compile step and as such it will become a part of the CI build.
Go to Visual Studio, right click Solution > Manage Nuget Packages > Install StyleCop.MSBuild.
That's it =)
We use the approach in the following articles successfully on a couple of projects...
http://blogs.msdn.com/sourceanalysis/pages/source-analysis-msbuild-integration.aspx http://blogs.msdn.com/sourceanalysis/archive/2008/11/11/introducing-stylecop-on-legacy-projects.aspx
basically you set a couple of environment variables up, reference them in all the .csproj files so that you can cater for different working directories for each individual developer, install the StyleCop MSBuild components on the build machine and you're off. No changes to the team build required.