Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling for ToolsVersion 12 with Visual Studio 2015

I setup a new computer and installed VS2015. Compiling the project I am currently work on results in some invalid code (ILSpy creates uncompilable sources). It worked fine in VS2013 using ToolsVersion 12.

Log file tells me that ToolsVersion 12 is missing, so I installed this. However whatever I do or set, it ALWAYS compiles using ToolsVersion 14. I can manually call MSBuild.exe shipped with VS2013 (uses ToolsVersion 12) and code is correct. Doing the same with MSBuild.exe shipped with VS2015 (uses ToolsVersion 14) results in the INCORRECT code. So all I need is VS2015 to use ToolSet 12.

MSDN says:

"Starting in Visual Studio 2013, the MSBuild Toolset version is the same as the Visual Studio version number. MSBuild defaults to this Toolset within Visual Studio and on the command line, regardless of the ToolSet version specified in project file. This behavior can be overridden by using the /ToolsVersion flag. For more information, see Overriding ToolsVersion Settings."

Setting such using MSBuild manually works fine, but how do I set this in VS 2015 ?? NONE of the environment variables work, it always uses toolset 14 !

like image 330
user1029883 Avatar asked Nov 18 '15 22:11

user1029883


1 Answers

I'm leaving this answer here in case it helps anyone else, however it hasn't helped the original poster, as according to @user1029883 it doesn't work when VS2015 is installed with the 12.0 Build Tools (see @alexandrul's comment below) instead of multiple versions of Visual Studio: sorry.


Unfortunately, there doesn't seem to be a straightforward way to do this. There is, however, a fiddly way:

  • Set the environment variable MSBUILDLEGACYDEFAULTTOOLSVERSION
  • Ensure the ToolsVersion attribute in the top-level Project element in all your project files is set to the desired ToolsVersion.

See the Overriding ToolsVersion Settings page on MSDN

like image 150
Guy Bolton King Avatar answered Nov 06 '22 00:11

Guy Bolton King