# Let Build Fail if there are FXCop or StyleCop errors

**URL:** <https://www.finalbuilder.com/forums/t/let-build-fail-if-there-are-fxcop-or-stylecop-errors/5437>\
**Category:** Discussion\
**Created:** [November 2, 2015, 10:28am UTC](https://www.finalbuilder.com/forums/t/let-build-fail-if-there-are-fxcop-or-stylecop-errors/5437 "2015-11-02T10:28:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![haggy](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/h/edb3f5/32.png) [@haggy](https://www.finalbuilder.com/forums/u/haggy)\
**Post date:** [November 2, 2015, 10:28am UTC](https://www.finalbuilder.com/forums/t/let-build-fail-if-there-are-fxcop-or-stylecop-errors/5437/1 "2015-11-02T10:28:48Z")

</div>

Hi  
  
is there a way to let a build fail if there are fxcop or stylecop violations (so not when there is only one general warning?)

---

<div class="post-metadata">

**Author:** ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)\
**Post date:** [November 3, 2015, 1:47am UTC](https://www.finalbuilder.com/forums/t/let-build-fail-if-there-are-fxcop-or-stylecop-errors/5437/2 "2015-11-03T01:47:53Z")

</div>

Hi Haggy,  
  
Assuming you are using an MSBuild action, you can add the following under a PropertyGroup in your csproj file.  
``

`
<CodeAnalysisTreatWarningsAsErrors>trueCodeAnalysisTreatWarningsAsErrors>
<RunCodeAnalysis>trueRunCodeAnalysis>
`
`
Use the following to treat general compiler warnings as errors: <TreatWarningsAsErrors>trueTreatWarningsAsErrors>
See this article for further details`

---

<div class="post-metadata">

**Author:** ![haggy](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/h/edb3f5/32.png) [@haggy](https://www.finalbuilder.com/forums/u/haggy)\
**Post date:** [November 3, 2015, 8:53am UTC](https://www.finalbuilder.com/forums/t/let-build-fail-if-there-are-fxcop-or-stylecop-errors/5437/3 "2015-11-03T08:53:14Z")

</div>

thx for your reply. is there also a possibility for stylecop?

---

<div class="post-metadata">

**Author:** ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)\
**Post date:** [November 3, 2015, 11:45am UTC](https://www.finalbuilder.com/forums/t/let-build-fail-if-there-are-fxcop-or-stylecop-errors/5437/4 "2015-11-03T11:45:10Z")

</div>

Hi Haggy,  
  
You can add this:

`<``StyleCopTreatErrorsAsWarnings``>false``StyleCopTreatErrorsAsWarnings``>`

  
Have have look at [this article](https://stylecop.codeplex.com/wikipage?title=Setting%20Up%20StyleCop%20MSBuild%20Integration)&nbsp;for further details
