使用Visual Studio 2015编译ToolsVersion 12 [英] Compiling for ToolsVersion 12 with Visual Studio 2015

查看:162
本文介绍了使用Visual Studio 2015编译ToolsVersion 12的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了一台新计算机并安装了VS2015.编译我当前正在处理的项目会导致一些无效代码(ILSpy创建无法编译的源代码).使用ToolsVersion 12在VS2013中运行良好.

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.

日志文件告诉我ToolsVersion 12丢失了,所以我安装了它.但是,无论我做什么或进行设置,它总是使用ToolsVersion 14进行编译.我可以手动调用VS2013附带的MSBuild.exe(使用ToolsVersion 12),并且代码正确.对VS2015附带的MSBuild.exe(使用ToolsVersion 14)执行相同操作会导致INCORRECT代码.因此,我需要的是VS2015以使用工具集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说:

从Visual Studio 2013开始,MSBuild Toolset版本与Visual Studio版本号相同.MSBuild在Visual Studio中和命令行上默认为此Toolset,与项目文件中指定的ToolSet版本无关.可以使用/ToolsVersion标志来覆盖此行为.有关更多信息,请参见覆盖ToolsVersion设置."

"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."

使用MSBuild手动进行此类设置可以正常工作,但是如何在VS 2015中进行设置?没有任何环境变量有效,它始终使用工具集14!

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 !

推荐答案

我将在这里留下这个答案,以防它对其他人有帮助,但是根据@ user1029883的说法,它对原始海报没有帮助VS2015与12.0生成工具(请参见下面的@alexandrul的注释)而不是Visual Studio的多个版本一起安装时不起作用:抱歉.

不幸的是,似乎没有一种直截了当的方式来做到这一点.但是,有一种奇怪的方法:

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

  • 设置环境变量MSBUILDLEGACYDEFAULTTOOLSVERSION
  • 确保将所有项目文件中顶级Project元素中的ToolsVersion属性设置为所需的ToolsVersion.
  • 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.

请参见MSDN上的 覆盖工具版本设置

See the Overriding ToolsVersion Settings page on MSDN

这篇关于使用Visual Studio 2015编译ToolsVersion 12的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆