问题描述
我正在将几个项目从 VS2010 迁移到 VS2019.这些项目的 vcxprojs 中有工具版本 4:
目标 VS 是 VS2019 v16.5.0,MSBuild 版本是 16.5.0.12403,所以我试图将 ToolsVersion 设置为 16.5:
但似乎 MSBuild 不喜欢它:
1> 使用工具版本当前"构建.1> 项目文件包含 ToolsVersion="16.5".此工具集可能未知或丢失,在这种情况下,您可以通过安装适当版本的 MSBuild 来解决此问题,或者由于策略原因,构建可能已被强制使用特定的 ToolsVersion.将项目视为具有 ToolsVersion="Current" 一样.
尽管构建成功,但我关心这条消息.这里有什么问题?
更新:
提供项目结构的简化示例:
常用道具:
cpp 道具:
<导入项目="common.props"/><-- 编译器、链接器设置等--></项目>
真实项目:
<-- 项目:cpp、headers 等--><-- 参考资料--><导入项目="$(VCTargetsPath)\Microsoft.Cpp.targets"/><ImportGroup Label="ExtensionTargets"></ImportGroup></项目>
要解决此问题,您应该进行一些更新.
建议
1),在VS2019 IDE上右键项目-->Retarget Projects
,将这个项目定位到Windows 10 SDK version
并选择 upgrade to v142
.
2),在VS2019 IDE上右击你的项目-->卸载项目-->编辑(项目名称).vcxproj-->更改ToolsVersion="4.0"
到 ToolsVersion="Current"
--> 然后重新加载你的项目
3) 右键单击您的项目-->Properties-->Configuration Properties-->General-->将 Platform Toolset
更改为 Visual Studio2019 v142
.
----------------更新1-----------
首先,ToolVersion
与包含在 Visual Studio 版本中的 MSBuild 版本有关.并且一般情况下,我们在 VS2019 中不使用 16.5
.请参阅
表示不能指定非法工具版本16.5
.
解决方案
1) 就像我之前说的,将 Realproject.vcxproj
中的工具版本更改为 Current
.
2)删除Realproject.vcxproj
中的toolversion
为了证明这一点,您可以创建一个新的 VS2019 c++ 项目,我确定您在 xxxx.vcxproj
文件中找不到 toolversion 节点.
然后在每个项目中尝试我的解决方案,我相信当你完成它时,信息不会再次出现.
I am doing the migration of several projects from VS2010 to VS2019. Those projects have Tools Version 4 in their vcxprojs:
<Project DefaultTargets="Build" ToolsVersion="4.0"
Target VS is VS2019 v16.5.0, MSBuild version is 16.5.0.12403, so I am trying to set ToolsVersion to 16.5:
<Project DefaultTargets="Build" ToolsVersion="16.5"
But it seems that MSBuild doesn't like it:
1>Building with tools version "Current".
1>Project file contains ToolsVersion="16.5". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="Current".
Despite builds are anyway successful, I care about this message. What can be wrong here?
UPD:
Providing simplified example of structure of projects:
common props:
<?
cpp props:
<?
Real project:
<?
To solve this issue, you should do some updates.
Suggestion
1), right-click on the project on VS2019 IDE-->Retarget Projects
and target this project to the Windows 10 SDK version
and choose upgrade to v142
.
2), Right-click your project on VS2019 IDE-->unload project-->Edit (project name).vcxproj-->change ToolsVersion="4.0"
to ToolsVersion="Current"
--> then reload your project
3) Right-click on your project-->Properties-->Configuration Properties-->General-->change Platform Toolset
to Visual Studio 2019 v142
.
----------------Update 1-----------
First of all, ToolVersion
is related to the version of MSBuild that is included in the Visual Studio edition like. And in general, we do not use 16.5
in VS2019. See this link. And actually, In VS2019, the ToolVersion is set to Current
.
VS2019-->Current, VS2017-->15.0,VS2015-->14.0
You cannot include a specific small version number.
This is my test result with your sample in my side and it seems that it is just like a warning:
It means that it cannot specify the Illegal toolversion 16.5
.
Solution
1) Just as I said before, change toolversion to Current
in Realproject.vcxproj
.
2) delete the toolversion
Realproject.vcxproj and in VS2019, it will automatically recognize toolversion without adding it manually.
To prove it, you can create a new VS2019 c++ project and I am sure that you cannot find toolversion node in xxxx.vcxproj
file.
Then try my solution into every projects and I am sure when you finish it, the info will not appear again.
这篇关于Visual Studio 2019 中的工具版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!