Building VC++ 2005 Projects With Team Build 2008

MSBuild introduced a multi-targeting feature in VS 2008 that allows it to build managed code projects that target previous versions of the .NET Framework (and all associated tools - the Microsoft.Common.targets file, the MSBuild engine itself, etc.).  Unfortunately, there is no corresponding functionality for VC++ projects, since these are still not MSBuild compatible project files.  MSBuild can build solutions containing VC++ projects, but there will be issues when building solutions containing VC++ 2005 (version 8) projects with the VS 2008 MSBuild engine (.NET Framework version 3.5) and thus with Team Build 2008.

In particular, you will notice messages similar to the following in your build log:

vcbuild.exe : error VCBLD0010: Project '<project name>' requires upgrade. Use 'vcbuild /upgrade' or 'devenv /upgrade' to upgrade the project.

The project file that MSBuild generates to build solutions uses something like the following VCBuild task invocation to build VC++ projects:

 <VCBuild Projects="foo.vcproj" 
         Condition=" ('$(Configuration)' == 'Configuration') and ('$(Platform)' == 'Platform') " />

The trick is that this will always use the VCBuild task from the 3.5 .NET Framework directory, and this task will always invoke VCBuild 2008.  Note, however, the VCBuildToolPath property - this allows you to override the path to vcbuild.exe used by the task, and provides the workaround that allows building VC++ 2005 projects without upgrading them.

In particular, you can add something like the following text to your TfsBuild.rsp file if all the solutions in your Team Build build contain VC++ 2005 projects:

/p:vcbuildtoolpath="$(ProgramFiles)\Microsoft Visual Studio 8\vc\vcpackages"

If some of your solutions contain VC++ 2005 projects and some contain VC++ 2008 projects, you can specify the property on a solution-specific basis using the Properties metadata of the SolutionToBuild item group as follows:

  <SolutionToBuild Include="VCBuild_2005.sln">
    <Properties>vcbuildtoolpath=$(ProgramFiles)\Microsoft Visual Studio 8\vc\vcpackages</Properties>
  <SolutionToBuild Include="VCBuild_2008.sln">