VC++ build failure after migration from TFS 2010 to 2012 if you have enabled code analysis

Follow comes from Deepak Mittal

 

Problem Description: After migration from 2010 to 2012 of VC++ projects and using Team Build 2012, if you have enabled code analysis, build might fail as it will consider warnings as error:

Error message in the log: Code analysis warning C6340 being treated as an error C2220

Resolution: This issue happening due to targets file working differently when you build the project with visual studio and when you build the solution with team build 2012. With visual studio, everything will work as expected.

To resolve the issue with Team Build 2012, here is the workaround:

  1. Open the proj file in notepad
  2. Find the CLCompile sections that build the cpp files (they have several properties set)
  3. Add the following property to all of those CLCompile elements:

              <AdditionalOptions>/analyze /analyze:quiet %(AdditionalOptions)</AdditionalOptions>

       4. Save the file and rebuild using Team Build