Build VS2010 Solutions Using TFS2008

We’ve been building VS2010 projects OK on a TFS2008 server until we tried to build a web deploy project (wdproj). And then we got an error as follows:

C:\Program Files (x86)\MSBuild\Microsoft\WebDeployment\v10.0\Microsoft.WebDeployment.targets(103, 46): error MSB4092: An unexpected token “)” was found at character position 174 in condition “‘$(_ExcludeWAPBaseIntermediateOutputPath)’ == ” And !$([System.IO.Path]::IsPathRooted($(_ExcludeWAPBaseIntermediateOutputPath)))”.

The issue was that TFS was using version 3.5 of msbuild (from Visual studio 2008). We tried just setting the ToolsVersion in the project build file to version 4.0 but that gave the error:

Project file contains ToolsVersion=“4.0”, which is not supported by this version of MSBuild

But TFS just defaulted back to 3.5 anyway and we got the same error. The solution is to change the version of MSBuild that TFS 2008 uses by following the steps below:

  • Stop the “Visual Studio Team Foundation Build” service
  • Go to C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies
  • Edit TfsBuildService.exe.config
  • Find the MSBuildPath setting and set the value as follows
  • <add key=”MSBuildPath” value=”c:\windows\microsoft.net\Framework\v4.0.30319″ />
  • Restart the service
  • Ensure your builds now work