Building VS2013 with a TFS2012 build agent
If you're like me, and I know I am, you've probably tried to make a TFS 2012 build agent build a VS2013 web project. You inevitably received this error from the build agent:
D:\Builds\1\Acme\Acme.Web.Api\Sources\Acme.Web.Api\Acme.Web.Api.csproj (407): The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.This is because of course you have VS2013 installed on your build agent machine, but you are using a VS2012 build agent to build a this project.
You can google lots of terrible answers including modifying the xml in the csproj file. If at all possible, I'd prefer not to modify the project since the problem looks like a build agent issue; the VS2013 project is going to be built by VS2013, so why change the project?
In this case, the correct answer appears to be the less up-voted answer on stackoverflow by Ralph Jansen: Add /p:VisualStudioVersion=12.0 to the MSBuild Arguments option in the Build Definition.
- Go to Team Explorer
- Select Build
- Select the build definition to modify
- Select Process
- Expand Advanced
- Add /p:VisualStudioVersion=12.0 to MSBuild Arguments
Save your build definition. Now go ahead and re-queue a build again, and your problem is likely solved.