The following are steps to include StyleCop in build process. It is based on: http://stylecop.codeplex.com/wikipage?title=Setting%20Up%20StyleCop%20MSBuild%20Integration&referringTitle=Documentation
You may want to change the 4.7 with the StyleCop version used in your project.
1. Download StyleCop
2. Copy the StyleCop binary {Program Files}\StyleCop4.7 to the repository solution folder: {Solution Folder}\ExternalTools\StyleCop\V4.7. Solution folder is where the VS solution file located.
3. Copy all of the files from {Program Files}\MSBuild\StyleCop to the {Solution Folder}\ExternalTools\StyleCop\V4.7 folder.
4. Edit {Solution Folder}\ExternalTools\StyleCop\V4.7\StyleCop.targets to make it to use the copied binary files in the same directory: <UsingTask AssemblyFile="StyleCop.dll" TaskName="StyleCopTask"/>
5. Put Settings.StyleCop in the {Solution Folder} to set solution-wide StyleCop rules.
The above steps are for the whole solution, for each project, you need complete the following steps.
6. Add one property definition in the project file <PropertyGroup>: <StyleCopTargets>..\ExternalTools\StyleCop\v4.7\StyleCop.targets</StyleCopTargets>
7. In the same project file, add the <Import Project="$(StyleCopTargets)" /> after <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
8. In the Debug <PropertyGroup>, set run code analysis to true: <RunCodeAnalysis>true</RunCodeAnalysis>
No comments:
Post a Comment