简体   繁体   English

Visual Studio 希望使用错误的平台工具集进行构建

[英]Visual Studio wants to build with wrong platform toolset

I have upgraded a solution from VS2010 to VS2012.我已经将一个解决方案从 VS2010 升级到 VS2012。 I did that with other solutions, and it worked fine.我用其他解决方案做到了这一点,而且效果很好。

But now when I tried to build the updated solution, the compiler tells me:但是现在当我尝试构建更新的解决方案时,编译器告诉我:

Error 1596  error MSB8020: The builds tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install Visual Studio 2010 to build using the Visual Studio 2010 build tools.    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets   42  5   praat3

I don't know why the compiler tries to use VS2010.我不知道为什么编译器会尝试使用 VS2010。

In the project property pages, I see under "Debug source files" the following entries:在项目属性页中,我在“调试源文件”下看到以下条目:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\
etc.

Also, if I set the "Platformtoolset" to "Inherit from project above or project standard", it defaults to "v100".此外,如果我将“Platformtoolset”设置为“从上面的项目或项目标准继承”,则默认为“v100”。 I think this is the best hint about what goes wrong here.我认为这是关于这里出了什么问题的最好提示。

By accident I managed to open up the Microsoft.Cpp.Platform.targets file, and I see that v90 and v100 are listed there, but not v110.偶然地,我设法打开了 Microsoft.Cpp.Platform.targets 文件,我看到那里列出了 v90 和 v100,但没有列出 v110。

Could somebody who uses only VS2012 perhaps have a look at that file?只使用 VS2012 的人可以看看那个文件吗?

This is what it looks like for me:这对我来说是这样的:

<!--
***********************************************************************************************
Microsoft.Cpp.Platform.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

This file defines the steps/targets required to build Visual C++ projects
specifically on x86 platforms.

Copyright (C) Microsoft Corporation. All rights reserved.
***********************************************************************************************
-->

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <ToolsetTargetsFound Condition="Exists('$(VCTargetsPath)\Platforms\$(Platform)\PlatformToolsets\$(PlatformToolset)\Microsoft.Cpp.$(Platform).$(PlatformToolset).targets')">true</ToolsetTargetsFound>
    <VCTargetsPathEffective Condition="'$(ToolsetTargetsFound)' == 'true'">$(VCTargetsPath)</VCTargetsPathEffective>
  </PropertyGroup>

  <!-- Import Before -->
  <Import Condition="Exists('$(VCTargetsPath)\Platforms\$(Platform)\ImportBefore')" Project="$(VCTargetsPath)\Platforms\$(Platform)\ImportBefore\*.targets"/>
  <!-- Import platform toolset file if found in this version -->
  <Import Condition="'$(ToolsetTargetsFound)' == 'true'" Project="$(VCTargetsPath)\Platforms\$(Platform)\PlatformToolsets\$(PlatformToolset)\Microsoft.Cpp.$(Platform).$(PlatformToolset).targets" />
  <!-- Try to find the toolset in older versions  -->
  <Import Condition="'$(ToolsetTargetsFound)' != 'true' and '$(MinSupportedVCTargetsVersion)' != 'v110'" Project="Microsoft.Cpp.Platform.Redirect.targets" />

  <PropertyGroup>
    <PrepareForBuildDependsOn>PlatformPrepareForBuild;$(PrepareForBuildDependsOn)</PrepareForBuildDependsOn>
  </PropertyGroup>

  <Target Name="PlatformPrepareForBuild" DependsOnTargets="$(PlatformPrepareForBuildDependsOn)">
    <PropertyGroup>
      <ConfigurationPlatformExists Condition="'%(ProjectConfiguration.Identity)' == '$(Configuration)|$(Platform)'">true</ConfigurationPlatformExists>
    </PropertyGroup>

    <!-- Error out when building an platform that is not set in the project file -->
    <VCMessage Code="MSB8013" Type="Error" Arguments="$(Configuration)|$(Platform)" Condition="'$(DesignTimeBuild)'!='true' and '$(ConfigurationPlatformExists)' != 'true'"/>

    <!-- Check if toolset exists in Visual Studio 2010 or Dev11 -->
    <VCMessage Code="MSB8020" Type="Error" Arguments="$(_PlatformToolsetShortNameFor_v100);$(PlatformToolset)" Condition="'$(DesignTimeBuild)'!='true' and '$(ToolsetTargetsFound)' != 'true' and '$(PlatformToolset)' == 'v100'" />
    <VCMessage Code="MSB8020" Type="Error" Arguments="$(_PlatformToolsetShortNameFor_v90);$(PlatformToolset)" Condition="'$(DesignTimeBuild)'!='true' and '$(ToolsetTargetsFound)' != 'true' and '$(PlatformToolset)' == 'v90'" />
    <VCMessage Code="MSB8020" Type="Error" Arguments="$(PlatformToolset);$(PlatformToolset)" Condition="'$(DesignTimeBuild)'!='true' and '$(ToolsetTargetsFound)' != 'true' and '$(PlatformToolset)' != 'v90' and '$(PlatformToolset)' != 'v100'" />
  </Target>

  <!-- Import After -->
  <Import Condition="'$(ToolsetTargetsFound)' == 'true' and Exists('$(VCTargetsPath)\Platforms\$(Platform)\ImportAfter')" Project="$(VCTargetsPath)\Platforms\$(Platform)\ImportAfter\*.targets"/>
</Project>

Thank you for the help.谢谢你的帮助。

The project is set to build with VS2010 compilers (platform toolset).该项目设置为使用 VS2010 编译器(平台工具集)构建。 You might have uninstalled VS2010 and got this error.您可能已卸载 VS2010 并收到此错误。

You can change the platform toolset in project properties->General->Platform Toolset.您可以在项目属性->常规->平台工具集中更改平台工具集。 Change it Visual Studio 2012.将其更改为 Visual Studio 2012。

Same error for me recently with VS2017.最近使用 VS2017 对我来说同样的错误。

Turned out the solution was merely missing a dependent project.原来解决方案只是缺少一个依赖项目。
If this is the cause, you should see something like:如果这是原因,您应该看到如下内容:

Done building project "someproject.vcxproj" -- FAILED.  

on the next line after the error message:在错误消息后的下一行:

error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found.

This error can be confusing since your projects may have already been retargeted.此错误可能会令人困惑,因为您的项目可能已被重新定位。

I have met the same issue as @Greg and @Jahmic when building OpenCV on Windows using CMake and VS 15 2017 (toolset v141).在使用 CMake 和 VS 15 2017(工具集 v141)在 Windows 上构建 OpenCV 时,我遇到了与 @Greg 和 @Jahmic 相同的问题。

I get this error:我收到此错误:

error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found.错误 MSB8020:找不到 Visual Studio 2010 的构建工具(平台工具集 = 'v100')。

It happens when the target config is not the first specified for DCMAKE_CONFIGURATION_TYPES in the CMAKE_ARGS.当目标配置不是第一个为 CMAKE_ARGS 中的 DCMAKE_CONFIGURATION_TYPES 指定时,就会发生这种情况。


EDIT (12/01/2020): clarification for Stanislav编辑(12/01/2020):对斯坦尼斯拉夫的澄清

It's been a while, so I hope I will not say wrong things or confuse you more since I am no expert... So take this answer very carefully please.已经有一段时间了,所以我希望我不会说错话或让您更加困惑,因为我不是专家......所以请非常小心地回答这个问题。

In my case, I was when building my project solution in a CI after adding OpenCV in our Superbuild.就我而言,在我们的 Superbuild 中添加 OpenCV 之后,我正在 CI 中构建我的项目解决方案。

The configuration of the Superbuild was done by these lines: Superbuild 的配置由以下几行完成:

cmake.exe -G "Visual Studio 15 2017" -A "x64" ../myProject/Superbuild
cmake.exe --build . --config RelWithDebInfo --target ALL_BUILD

But OpenCV doesn't support the config RelWithDebInfo.但是 OpenCV 不支持配置 RelWithDebInfo。 Indeed, in our External-OpenCV.cmake file I can find:事实上,在我们的 External-OpenCV.cmake 文件中,我可以找到:

ExternalProject_Add(OpenCV GIT_REPOSITORY "https://github.com/opencv/opencv.git" GIT_TAG "${OPENCV_TAG}" SOURCE_DIR OpenCV BINARY_DIR OpenCV-build #CMAKE_GENERATOR ${gen} #CMAKE_GENERATOR_PLATFORM "x64" CMAKE_ARGS ${ep_common_args} -DCMAKE_CONFIGURATION_TYPES:STRING=Release;Debug; -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_WITH_STATIC_CRT:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_WITH_DEBUG_INFO:BOOL=ON -DBUILD_DOCS:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_PERF_TESTS:BOOL=OFF -DBUILD_TESTS:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=${OPENCV_INSTALL_DIR} ExternalProject_Add(OpenCV GIT_REPOSITORY "https://github.com/opencv/opencv.git" GIT_TAG "${OPENCV_TAG}" SOURCE_DIR OpenCV BINARY_DIR OpenCV-build #CMAKE_GENERATOR ${gen} #CMAKE_GENERATOR_PLATFORM "x64" $CMAKEs_argation_GIT_TAG "${OPENCV_TAG}" SOURCE_DIR :STRING=Release;Debug; -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_WITH_STATIC_CRT:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_WITH_DEBUG_INFO:BOOL=ON -DBUILD_DOCS:BOOL=OFF -DBUILD_WITH_STATIC_CRT:BOOL=OFF DBUILD_TESTS:BOOL=OFF -DCMAKE_INSTALL_PREFIX:PATH=${OPENCV_INSTALL_DIR}

So the lines have been changed to these ones:所以这些行已更改为这些:

cmake.exe -G "Visual Studio 15 2017" -A "x64" -T v141 ../myProject/Superbuild
cmake.exe --build . --config Release --target ALL_BUILD

Now we have understood that we didn't need to add the target platform option ( -T v141 ) so it has been removed.现在我们已经明白我们不需要添加目标平台选项 ( -T v141 ),因此它已被删除。

Under "C/C++", there was a lib in "Additional include directories".在“C/C++”下,“附加包含目录”中有一个库。 I did not use this lib, but it was referenced.我没有使用这个库,但它被引用了。 I removed this lib.我删除了这个库。

I also deleted all "studio 2010" entries in the registry.我还删除了注册表中的所有“studio 2010”条目。

I know this is an old thread, but perhaps this might help somebody else who comes here because of similar issues.我知道这是一个旧线程,但也许这可能会帮助因类似问题来到这里的其他人。

I had a similar problem.我有一个类似的问题。 VS 2015 Community (MSBuild 14) building a c++ app, wanted to use VS 2010 (v100) tools. VS 2015 社区 (MSBuild 14) 构建了一个 c++ 应用程序,想使用 VS 2010 (v100) 工具。 It all came down giving msbuild an invalid configuration option.这一切都给了 msbuild 一个无效的配置选项。 Strange.奇怪。

So, recheck all those options and parameters.因此,请重新检查所有这些选项和参数。

I had the same issue and found out in was caused by calling msbuild without options, ie :我遇到了同样的问题,发现是由于在没有选项的情况下调用msbuild引起的,

msbuild myLib.vcxproj

Calling it with an explicit target solved the issue, ie :用明确的目标调用它解决了这个问题,

msbuild myLib.vcxproj t:Rebuild /p:Configuration=Release;Platform=x64

Maybe it helps someone 🙂也许它可以帮助某人🙂

In my case, I was building using the MSbuild command for VS2017.就我而言,我使用 VS2017 的 MSbuild 命令进行构建。

The problem was an incomplete conversion of the VS solution file which was partially VS2010 and partially VS2017;问题是VS解决方案文件转换不完整,部分是VS2010,部分是VS2017; converting individual projects within the solution did not correct the problem, since the solution file is used at the build level to define the build version.转换解决方案中的单个项目并没有解决问题,因为在构建级别使用解决方案文件来定义构建版本。

To correct it, I used the /Upgrade switch on the command line:为了更正它,我在命令行上使用了/Upgrade开关:

SET msbuild="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe"

%msbuild% .\MyNiceProject.sln /Upgrade

After that, then I could compile the project from the command line without the error message:之后,我可以从命令行编译项目而不会出现错误消息:

%msbuild% .\MyNiceProject.sln /Rebuild "Release|Win32" /Out .\buildinfo.log

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio 平台工具集与 Windows SDK - Visual studio platform toolset vs Windows SDK Visual Studio Platform工具集和运行时库 - Visual Studio Platform toolset and Runtime Library 什么是 Visual Studio 项目中的“平台工具集”设置 - What is "Platform Toolset" setting in visual studio project 找不到Visual Studio 2008的生成工具(Platform Toolset =&#39;v90&#39;) - The build tools for Visual Studio 2008 (Platform Toolset = 'v90') cannot be found 增强visual studio 2013 XP工具集的功能 - Build boost on visual studio 2013 XP toolset 如何将Visual Studio 2005的平台工具集添加到较新IDE版本的“Platform Toolset”列表中? - How can I add the platform toolset of Visual Studio 2005 into the `Platform Toolset` list of the newer IDE versions? 使用Visual Studio 2012并使用较旧的平台工具集进行编译? - Use Visual Studio 2012 and compile with older platform toolset? 找不到 Visual Studio Platform 2015 工具集 =&#39;v141&#39; - Visual Studio Platform 2015 Toolset ='v141' cannot be found Visual Studio _MSC_VER与平台工具集 - Visual Studio _MSC_VER versus Platform Toolset Visual Studio:如何使用平台工具集作为预处理器指令? - Visual Studio: How to use platform toolset as preprocessor directive?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM