Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StyleCop should cancel build. Is this possible?

I am planning to use StyleCop in my project. My requirement is that the project should not get compiled when StyleCop returns a warning. Nor debugging should be possible.

I have already integrated StyleCop into MSBuild as described at http://blogs.msdn.com/b/sourceanalysis/archive/2008/05/24/source-analysis-msbuild-integration.aspx. It is throwing errors when I build. But, when I start debugging, it is possible (Means, it is possible for programmer to override StyleCop). I can see that the build process is not getting cancelled and all dlls are created.

Is it possible to cancel the build when StyleCop throws errors ?

Thanks,

Madhu

like image 289
Madhu Avatar asked Feb 26 '23 16:02

Madhu


1 Answers

to show warnings of StyleCop as errors you can add next line into your *.csproj file:

<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>

to avoid compiling with stylecop errors you can use StyleCop's target just adding a line into same project file:

<Import Project="$(SolutionDir)\LOCAL_PATH\Microsoft.StyleCop.targets" />

After adding this line you will not compile project with StyleCop warnings(errors).

like image 192
breez Avatar answered Mar 10 '23 12:03

breez