Partager via


$(CodeAnalysisTreatWarningsAsErrors) MSBuild property

For Visual Studio 2008, we have added a new MSBuild property that allows you to easily treat all Code Analysis warnings as build errors. This can be useful for example, if you want to force that any firing of a Code Analysis rule to break the build during a nightly Team Build without needing to individually set this for every rule.

To use, simply add the <CodeAnalysisTreatWarningsAsErrors> property to your project file (or a common targets file) and set it to true:

CodeAnalysisTreatWarningsAsErrors MSBuild property

Now, in the next run of Code Analysis, all rules will be displayed as errors:

Error List with Code Analysis errors

Comments

  • Anonymous
    August 08, 2007
    In VS2008, is integrated code analysis still relegated to the Team editions of VS? FxCop? /analyze (C++)? (If I ever get a free moment, I'll actually install Beta 2 and check for myself...) I've always failed to understand the tying to the Team editions as both FxCop and PREFast are freely available (The Vista SDK includes a C++ compiler with /analyze enabled).

  • Anonymous
    November 22, 2007
    In previous posts about Code Metrics and Code Reviews , I explored some metrics and techniques that I