[英]Visual Studio wants to build with wrong platform toolset
我已經將一個解決方案從 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>
謝謝你的幫助。
該項目設置為使用 VS2010 編譯器(平台工具集)構建。 您可能已卸載 VS2010 並收到此錯誤。
您可以在項目屬性->常規->平台工具集中更改平台工具集。 將其更改為 Visual Studio 2012。
最近使用 VS2017 對我來說同樣的錯誤。
原來解決方案只是缺少一個依賴項目。
如果這是原因,您應該看到如下內容:
Done building project "someproject.vcxproj" -- FAILED.
在錯誤消息后的下一行:
error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found.
此錯誤可能會令人困惑,因為您的項目可能已被重新定位。
在使用 CMake 和 VS 15 2017(工具集 v141)在 Windows 上構建 OpenCV 時,我遇到了與 @Greg 和 @Jahmic 相同的問題。
我收到此錯誤:
錯誤 MSB8020:找不到 Visual Studio 2010 的構建工具(平台工具集 = 'v100')。
當目標配置不是第一個為 CMAKE_ARGS 中的 DCMAKE_CONFIGURATION_TYPES 指定時,就會發生這種情況。
編輯(12/01/2020):對斯坦尼斯拉夫的澄清
已經有一段時間了,所以我希望我不會說錯話或讓您更加困惑,因為我不是專家......所以請非常小心地回答這個問題。
就我而言,在我們的 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-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}
所以這些行已更改為這些:
cmake.exe -G "Visual Studio 15 2017" -A "x64" -T v141 ../myProject/Superbuild
cmake.exe --build . --config Release --target ALL_BUILD
現在我們已經明白我們不需要添加目標平台選項 ( -T v141 ),因此它已被刪除。
在“C/C++”下,“附加包含目錄”中有一個庫。 我沒有使用這個庫,但它被引用了。 我刪除了這個庫。
我還刪除了注冊表中的所有“studio 2010”條目。
我知道這是一個舊線程,但也許這可能會幫助因類似問題來到這里的其他人。
我有一個類似的問題。 VS 2015 社區 (MSBuild 14) 構建了一個 c++ 應用程序,想使用 VS 2010 (v100) 工具。 這一切都給了 msbuild 一個無效的配置選項。 奇怪。
因此,請重新檢查所有這些選項和參數。
我遇到了同樣的問題,發現是由於在沒有選項的情況下調用msbuild
引起的,即:
msbuild myLib.vcxproj
用明確的目標調用它解決了這個問題,即:
msbuild myLib.vcxproj t:Rebuild /p:Configuration=Release;Platform=x64
也許它可以幫助某人🙂
就我而言,我使用 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.