I am trying to get builds to fail if they do not pass StyleCop. Currently, these are only being displayed as warnings. I have tried to follow the documentation here.
I have added to my CSProj file <Import Project="$(ProgramFiles)\MSBuild\StyleCop\v4.7\StyleCop.targets" />
which seems to correctly include StyleCop.
Then, I added the StyleCopTreatErrorsAsWarnings
set to false in my csproj file. Here is the start of my CSProj file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(ProgramFiles)\MSBuild\StyleCop\v4.7\StyleCop.Targets" />
<PropertyGroup>
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
This causes, in Bamboo (my continuous integration server) warnings to appear, but no errors. The same occurs in Visual Studio.
Why are StyleCop errors still appearing as warnings?