Unable to make StyleCop errors appear as build errors (not warnings)

I am trying to get builds for crashes if they don't skip StyleCop. They are currently only displayed as warnings. I tried to follow the documentation here .

I added to my CSProj file <Import Project="$(ProgramFiles)\MSBuild\StyleCop\v4.7\StyleCop.targets" /> , which seems to include StyleCop correctly.

Then I added the StyleCopTreatErrorsAsWarnings parameter to false in my csproj file. Here is the beginning 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 leads to warnings in Bamboo (my continuous integration server), but no errors. The same thing happens in Visual Studio.

Why are StyleCop errors still appearing as warnings?

+6
source share
1 answer

you need to transfer the style import after the C # import line. You also need to add the StyleCopEnabled = true property to the csproj file

+1
source

Source: https://habr.com/ru/post/978212/


All Articles