简体   繁体   中英

ToolsVersion in Visual Studio 2019

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" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

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" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

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:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
        <ShouldUnsetParentConfigurationAndPlatform>false</ShouldUnsetParentConfigurationAndPlatform>
</PropertyGroup>
<PropertyGroup Label="Globals">
        <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
        <DotNetFrameworkVersion>v4.0</DotNetFrameworkVersion>
</PropertyGroup>
<!-- Other common variables-->
</Project>

cpp props:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup Label="Configuration">
        <ConfigurationType>DynamicLibrary</ConfigurationType>
    </PropertyGroup>

    <PropertyGroup>
        <TargetExt>.dll</TargetExt>
    </PropertyGroup>

   <PropertyGroup Label="Configuration">
        <PlatformToolset>v142</PlatformToolset>
    </PropertyGroup>

    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
    <Import Project="common.props" />

    <-- compiler, linker settings and so on -->
</Project>

Real project:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="16.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup Label="Globals">
    <ProjectName>my_name</ProjectName>
    <ProjectGuid>{my_guid}</ProjectGuid>
    <RootNamespace>my_ns</RootNamespace>
    <Keyword>my_keyword</Keyword>
  </PropertyGroup>
  <Import Project="cpp.props" />
  <-- configurations (Release, Debug, x64/Win32 and so on -->
  <-- project-specific compiler/linker settings -->
  <-- items: cpp, heanders and so on -->
  <-- references -->
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
  </ImportGroup>
</Project>

Project file contains ToolsVersion="16.5". This toolset may be unknown or missing

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 xml node in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM