Skip to content

CruiseControl.NET: StyleCop configuration

March 1, 2011

In this post we are going to describe StyleCop configuration for CruiseControl.NET (for 1.5 RC1 release and higher only).

Follow the steps:

1. Install StyleCop on machine where Cruise Control .NET located (actually must be you buil server).

2. Create msbuild.proj file in you MS Visual Studio project folder (where solution file is). Insert the code into created file:

 <?xml version="1.0" encoding="utf-8"?>
<Project xmlns="" ToolsVersion="3.5">

 <!-- After DEBUG Compile -->
 <!-- FxCop -->
 <Target Name="FxCop" />

 <!-- StyleCop -->
 <UsingTask AssemblyFile="C:\Program Files (x86)\Microsoft StyleCop\Microsoft.StyleCop.dll" TaskName="StyleCopTask"/>
 <!-- Add Project to Analyze with StyleCop here -->
 <Project Include="$(SolutionRoot)\**\*.csproj" />
 <Target Name="StyleCop">
 <Message Text="Running StyleCop..." />
 <CreateItem Include="%(Project.RootDir)%(Project.Directory)**\*.cs"
 <Output TaskParameter="Include" ItemName="StyleCopFiles" />
 <StyleCopTask ProjectFullPath="$(MSBuildProjectFile)"
 <Message Text="StyleCop executed" />


3. Insert the following code into tasks section of config file:

<!--after debug compile-->
<!--after debug compile-->
 <description>Running - After DEBUG Compile</description>
 <executable>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable><!--Путь до MSBuild.exe файла-->
 <projectFile>C:\project1\working\project1\msbuild.proj</projectFile><!--Путь до созданного нами файла. Напоминаю, он должен быть в той же папке, где располагается solution файл проекта.-->
 <buildArgs>/noconsolelogger /p:SolutionRoot=C:\_sunflower\working /v:diag</buildArgs>
 <logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>

5. Actually that is all but we also want to visualize StyleCop results. To do it we need to modify web dashboard config file and put XSLT files for StyleCop (by default in %programs_files%)\CruiseControl.NET\webdashboard\dashboard.config):

 <xslFile>xsl\stylecop-summary_4_3.xsl</xslFile><!--We are addint this line-->
<xslReportBuildPlugin description="MSTest 2008 Detail Report" actionName="MSTEST2008DetailReport" xslFileName="xsl\MsTestReport2008.xsl" />
<xslReportBuildPlugin description="StyleCop Report" actionName="StyleCopBuildReport" xslFileName="xsl\StyleCopReport.xsl" /><!--We are adding this line-->

6 . Upload and copy to server (%programs_files%\CruiseControl.NET\webdashboard\xsl\ ) the following files
StyleCopReport и StyleCopSummary

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: