Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't know how familiar you are with MSBuild, but you should be able to add a new Build Step in TC 6 and above, and set MSBuild as the build runner, and point it to a .proj file which does something similar to the following:</p> <pre><code>&lt;Target Name="StyleCop"&gt; &lt;!-- Create a collection of files to scan --&gt; &lt;CreateItem Include="$(SourceFolder)\**\*.cs"&gt; &lt;Output TaskParameter="Include" ItemName="StyleCopFiles" /&gt; &lt;/CreateItem&gt; &lt;StyleCopTask ProjectFullPath="$(MSBuildProjectFile)" SourceFiles="@(StyleCopFiles)" ForceFullAnalysis="true" TreatErrorsAsWarnings="true" OutputFile="StyleCopReport.xml" CacheResults="true" /&gt; &lt;Xslt Inputs="StyleCopReport.xml" RootTag="StyleCopViolations" Xsl="tools\StyleCop\StyleCopReport.xsl" Output="StyleCopReport.html" /&gt; &lt;XmlRead XPath="count(//Violation)" XmlFileName="StyleCopReport.xml"&gt; &lt;Output TaskParameter="Value" PropertyName="StyleCopViolations" /&gt; &lt;/XmlRead&gt; &lt;Error Condition="$(StyleCopViolations) &gt; 0" Text="StyleCop found $(StyleCopViolations) broken rules!" /&gt; &lt;/Target&gt; </code></pre> <p>If you don't want to fail the build on a StyleCop error, then set the <code>Error</code> task to be <code>Warning</code> instead.</p> <p>You'll also need to add the following to your .proj file:</p> <pre><code>&lt;UsingTask TaskName="StyleCopTask" AssemblyFile="$(StyleCopTasksPath)\Microsoft.StyleCop.dll" /&gt; </code></pre> <p><code>Microsoft.StyleCop.dll</code> is included in the StyleCop installation, and you'll need to set your paths appropriately.</p> <p>To see the outputted StyleCop results in TeamCity, you will need to transform the .xml StyleCop report to HTML using an appropriate .xsl file (called StyleCopReport.xsl in the script above).</p> <p>To display the HTML file in TeamCity, you'll need to create an <a href="http://confluence.jetbrains.net/display/TCD6/Configuring+General+Settings#ConfiguringGeneralSettings-ArtifactPaths" rel="noreferrer">artifact</a> from this .html output, and then <a href="http://confluence.jetbrains.net/display/TCD6/Including+Third-Party+Reports+in+the+Build+Results" rel="noreferrer">include that artifact in the build results</a>.</p> <p>The <a href="http://www.manning.com/kawalerowicz/" rel="noreferrer">Continuous Integration in .NET</a> book is a great resource.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload