【问题标题】:Visual Studio wants to build with wrong platform toolsetVisual Studio 想要使用错误的平台工具集进行构建
【发布时间】:2013-12-16 01:35:39
【问题描述】:

我已将解决方案从 VS2010 升级到 VS2012。 我用其他解决方案做到了这一点,并且效果很好。

但是现在当我尝试构建更新的解决方案时,编译器告诉我:

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

不知道为什么编译器会尝试使用VS2010。

在项目属性页中,我在“调试源文件”下看到以下条目:

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.

另外,如果我将“Platformtoolset”设置为“从上面的项目或项目标准继承”,它默认为“v100”。我认为这是关于这里出了什么问题的最佳提示。

我无意中打开了 Microsoft.Cpp.Platform.targets 文件,我看到那里列出了 v90 和 v100,但没有列出 v110。

只使用 VS2012 的人可以看看那个文件吗?

这对我来说是这样的:

<!--
***********************************************************************************************
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>

感谢您的帮助。

【问题讨论】:

    标签: c++ visual-studio-2010 visual-studio-2012 build-tools


    【解决方案1】:

    该项目设置为使用 VS2010 编译器(平台工具集)构建。您可能已经卸载了 VS2010 并收到此错误。

    您可以在项目属性->常规->平台工具集中更改平台工具集。 将其更改为 Visual Studio 2012。

    【讨论】:

    • 解决方案中的项目已设置为“Visual Studio 2012 (v110)”。
    • 尝试在文本编辑器中打开项目文件并查找v100。都应该是 v110。还要检查$(VCInstallDir) 的值。如果这被定义为环境变量,则需要将其删除。它应该指向VS2012的安装目录。
    • 都是否定的。变量未设置,项目文件不包含 v100。
    【解决方案2】:

    我最近在 VS2017 上遇到了同样的错误。

    原来解决方案只是缺少一个依赖项目。
    如果这是原因,您应该会看到如下内容:

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

    在错误信息后的下一行:

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

    此错误可能会造成混淆,因为您的项目可能已被重新定位。

    【讨论】:

    • 同样,我传入的配置属性中的名称无效。错误是红鲱鱼。
    • 还传入了无效的配置属性(一个空字符串)并得到了相同的错误消息。可以确认错误消息是一条红鲱鱼(即错误的、误导性的错误消息)。
    【解决方案3】:

    在使用 CMake 和 VS 15 2017(工具集 v141)在 Windows 上构建 OpenCV 时,我遇到了与 @Greg 和 @Jahmic 相同的问题。

    我收到此错误:

    错误 MSB8020:Visual Studio 2010 的构建工具(平台工具集 = 'v100') 找不到。

    当目标配置不是 CMAKE_ARGS 中 DCMAKE_CONFIGURATION_TYPES 的第一个指定时,就会发生这种情况。


    编辑(2020 年 12 月 1 日): 澄清斯坦尼斯拉夫

    已经有一段时间了,所以我不是专家,所以我希望我不会说错话或让你更加困惑......所以请认真对待这个答案。

    在我的例子中,我在我们的 Superbuild 中添加 OpenCV 后,在 CI 中构建我的项目解决方案。

    Superbuild 的配置是通过以下几行完成的:

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

    但是 OpenCV 不支持配置 RelWithDebInfo。 事实上,在我们的 External-OpenCV.cmake 文件中,我可以找到:

    ExternalProject_Add(OpenCV GIT_REPOSITORY "https://github.com/opencv/opencv.git" GIT_TAG "${OPENCV_TAG}" SOURCE_DIR OpenCV BINARY_DIR OpenCV 构建 #CMAKE_GENERATOR ${gen} #CMAKE_GENERATOR_PLATFORM "x64" CMAKE_ARGS ${ep_common_args} -DCMAKE_CONFIGURATION_TYPES:STRING=发布;调试; -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_WITH_STATIC_CRT:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=发布 -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}

    所以这些行已更改为这些行:

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

    现在我们了解到,我们不需要添加目标平台选项(-T v141),因此已将其删除。

    【讨论】:

    • 谢谢你的回答,你能用一个例子澄清一下吗?我遇到了类似的问题,但由于缺乏 CMake 知识而无法解决
    • 嗨,我已经更新了我的答案。希望对你有帮助。
    【解决方案4】:

    在“C/C++”下,“其他包含目录”中有一个库。我没有使用这个库,但它被引用了。我删除了这个库。

    我还删除了注册表中的所有“studio 2010”条目。

    【讨论】:

      【解决方案5】:

      我知道这是一个旧线程,但也许这可能会对因类似问题而来到这里的其他人有所帮助。

      我遇到了类似的问题。 VS 2015 Community (MSBuild 14) 构建一个 c++ 应用程序,想使用 VS 2010 (v100) 工具。这一切都给 msbuild 一个无效的配置选项。奇怪。

      所以,重新检查所有这些选项和参数。

      【讨论】:

      • 通常应该通过VS2015的“升级项目”提示修复,但我也发现它并不总是有效。
      【解决方案6】:

      我遇到了同样的问题,发现是由于在没有选项的情况下调用 msbuild 引起的,

      msbuild myLib.vcxproj
      

      使用明确的目标调用它解决了这个问题,

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

      也许它可以帮助某人?

      【讨论】:

        【解决方案7】:

        就我而言,我是使用 VS2017 的 MSbuild 命令构建的。

        问题是VS解决方案文件转换不完整,部分是VS2010,部分是VS2017;在解决方案中转换单个项目并不能解决问题,因为解决方案文件在构建级别用于定义构建版本。

        为了更正它,我在命令行上使用了/Upgrade 开关:

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

        之后,我可以从命令行编译项目而不会出现错误消息:

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

        【讨论】:

          猜你喜欢
          • 2022-07-05
          • 2021-04-12
          • 1970-01-01
          • 2013-03-05
          • 1970-01-01
          • 2020-08-14
          • 2017-07-28
          • 2016-04-26
          • 2016-01-14
          相关资源
          最近更新 更多