1

I started down this path of wanting to do code analysis on my solution using msbuild. I was looking at FxCop but it appears to now be part of Visual Studio and from my understanding you need Visual Studio installed on your build agents.

I am calling msbuild from a powershell using the following command;

"$(get-content env:systemroot)\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /tv:4.0 /p:RunCodeAnalysis=Always"

It appears to run the code analysis and output warnings but never fails the build, even after I added <CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors> to my .csproj file.

All I want is to run code analysis from msbuild command line and have it fail the build if any warning is found. I understand it can be done in Visual Studio but I need to be able to run this from the command line (with/without VS2013)

Am I missing something? Shouldn't /p:RunCodeAnalysis=Always and setting the CodeAnalysisTreatWarningsAsErrors to true be all that is needed?

devfunkd
  • 3,164
  • 12
  • 45
  • 73
  • As an aside I find `$(get-content env:systemroot)` to be odd since `Get-Content` is for reading files. `$($env:systemroot)` would work just as well in its place. – Matt Mar 13 '15 at 17:23
  • Hah! You're right good point... oops, ;) – devfunkd Mar 13 '15 at 17:43
  • Getting stuck with this problem every few months! Finally found the solution I hope I won't forget about next time. See related [SO answer](https://stackoverflow.com/a/14369929/4207332). – Serhii Shushliapin Jun 09 '17 at 15:06

0 Answers0