Using 2013 msbuild in program with Project.Build

c#, msbuild, visual-studio-2013

Solution

MSBuild and its Toolset now Version with Visual Studio

We plan to evolve our build tools with each version of Visual Studio from now on. Each release of the Micrsoft® Build Tools will have a new version of MSBuild, the VB/C# Compilers, and Toolset. They will all version together. Visual Studio will use its corresponding version of MSBuild exclusively. For instance, Visual Studio 2013 will exclusively use MSBuild 2013 and ToolsVersion=”12.0”. To align with Visual Studio’s versioning we have updated MSBuild’s assembly version from 4.0 to 12.0 as well.

And a link to the visual studio team page, with a few additional defaults to check

http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx

however 4.0 and version 12 are the same; re-versioned to support the visual studio version number format

Problem

Our tests use Microsoft.Build.Evaluation.Project.Build to build projects. Works fine for VS 2010 & 2012. Trouble is in VS 2013, it picks up msbuild from ``` C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe ver 4.0.30319.18408 ``` instead of from VS 2013 ``` C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe ver 12.0.21005.1 ``` Is there any method to ask it to pick up the VS 2013 msbuild? May be adding to the .proj file or setting an environment value before calling the build method?

Original source