适用于.NET Framework 4.6的Visual Studio 2015 CSProj ToolsVersion [英] Visual studio 2015 csproj ToolsVersion for .net framework 4.6

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

问题描述

看来,升级的项目越来越ToolsVersion = 12时TargetFramework选的是" .Net框架4.6"在Visual Studio 2015中进行.我使用Visual Studio 2010之前的版本从.net Framework 4升级了我的项目.

It seems that the upgraded projects are getting ToolsVersion=12 when TargetFramework chosen is ".Net Framework 4.6" inside visual studio 2015. I upgraded my project from .net Framework 4 using earlier with visual studio 2010.

但是HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ MSBuild \ ToolsVersions的条目为14.

However HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions has an entry for 14.

我的想法是视觉工作室2015 应该升级项目Toolsversion = 14时TargetFramework选的是" .Net框架4.6". 已使用Toolsversion = 14正确创建了新项目.

My thinking is that visual studio 2015 should upgrade projects with Toolsversion=14 when TargetFramework chosen is ".Net Framework 4.6".  The new projects are properly being created with Toolsversion=14.

该站点: https://msdn.microsoft.com/en-us/library/bb383796. aspx  提到:从Visual Studio 2013开始,MSBuild Toolset版本与Visual Studio版本相同 数字.无论在项目文件中指定的工具集版本如何,MSBuild都默认在Visual Studio中和命令行上使用此工具集.

The site: https://msdn.microsoft.com/en-us/library/bb383796.aspx mentions: "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."

这说明了为什么在Visual Studio中可以成功进行编译,但是我不明白为什么Visual Studio会将12作为ToolsVersion放置在项目文件中而不是14中.如果有人的构建过程/脚本依赖于 ToolsVersion.

This explains why compilation is successful from within visual studio but I do not understand why visual studio would put 12 as ToolsVersion in the project files instead of 14. This probably would impact if someone's build process/script is relying on the ToolsVersion.

除了我以外,还有其他人注意到吗?请告知我是否有遗漏或认为我的帖子是固定的.

Has someone other than me also noticed it? Please advise if I am missing something or consider my post as fyi.

推荐答案

BikGor,

Hi BikGor,

我已转载您的问题.如果我们将目标框架更改为4.6,则仅将ToolsVersion更改为12.0.在将目标框架更改为4.6时,我没有找到有关VS如何更新此属性的任何文档,我猜想它使用了 VS2013.但是,如果我们创建一个针对.Net Framework 4.5/4.6的新项目,则此属性的值为14.0.

I've reproduced your problem. If we change the target framework to 4.6, it only change the ToolsVersion to 12.0. I didn't find any documentation about how VS update this attribute when changing the target framework to 4.6, I guess it uses the mechanism in VS2013. But if we create a new project targeting to .Net Framework 4.5/4.6, the value of this attribute is 14.0.

我认为,正确的方法是在更改项目的目标框架之后手动更改此属性.或不要依赖此属性,因为这是不可靠的.如果使用MSBuild.exe来构建/ToolsVersion参数,请指定 这类项目.

The proper way, in my opinion, is to manually change this attribute after changing the Target Framework of the project. Or don't depend on this attribute since this is not reliable. Specify the /ToolsVersion parameter if you use MSBuild.exe to build such kind of projects.


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

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