gpt4 book ai didi

c++ - VS 2017 构建工具失败,错误 MSB4019 : The imported project "D:\Microsoft.Cpp.Default.props" was not found

转载 作者:行者123 更新时间:2023-11-30 01:37:02 25 4
gpt4 key购买 nike

我正在构建一个新的 TFS 构建服务器,并决定使用 VS 2017 构建工具,而不是安装完整版本的 VS。当我尝试构建 C++ 项目时,它抛出以下错误:

Error MSB4019: The imported project "D:\Microsoft.Cpp.Default.props" was not found.

经过几个小时的研究,我还没有更接近解决这个问题。我尝试添加以下注册表设置,但没有帮助。

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0]
"VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V140\'))"
"VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V110\'))"
"VCTargetsPath14"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath14)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V140\'))"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0\11.0]
"VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V110\'))"
"VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V110\'))"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0\14.0]
"VCTargetsPath"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V140\'))"
"VCTargetsPath11"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath11)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V110\'))"
"VCTargetsPath14"="$([MSBuild]::ValueOrDefault('$(VCTargetsPath14)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V140\'))"

我猜测该产品的 Microsoft 安装程序已损坏。是否有针对此错误的标准修复,或者我应该放弃我的努力并简单地安装完整版本?

在项目文件中,我找到了这个条目:

<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />

所以,我猜这意味着变量 VSTargetsPath 以某种方式指向 D: 驱动器的根目录,但我不知道在哪里设置该值。我们当前的构建服务器没有名为 VSTargetsPath 的环境变量集,但它确实缺少注册表项。它还安装了完整版本的 VS。

最佳答案

VS 2017 Build Tools failing with Error MSB4019: The imported project “D:\Microsoft.Cpp.Default.props” was not found

尝试将 VCTargetsPath 作为属性从构建配置显式传递给 msbuild:

  1. 编辑构建的构建定义。

  2. 单击“进程”选项卡。

  3. 在“高级”部分中,设置 MSBuild 参数以包含以下属性:

    /p:VCTargetsPath="C:\Program Files (x86)\Microsoft Visual Studio\2017\xxx\Common7\IDE\VC\VCTargets\"

  4. 保存构建定义。

注意:您应该将 VCTargetsPath 的值更改为 VCTargets 文件夹的位置。

或者VisualStudioVersion 作为属性传递给 msbuild:/p:VisualStudioVersion=15.0

如果您对 $(VCTargetsPath) 的值感兴趣,您可以查看以下线程以获取更多详细信息:

Can't find registry entries for Visual Studio 2017

Visual Studio Locator

Over the years Visual Studio could be discovered using registry keys,but with recent changes to the deployment and extensibility models anew method is needed to discover possibly more than once installedinstance. These changes facilitate a smaller, faster default installcomplimented by on-demand install of other workloads and components.

vswhere is designed to be a redistributable, single-file executablethat can be used in build or deployment scripts to find where VisualStudio - or other products in the Visual Studio family - is located.For example, if you know the relative path to MSBuild, you can findthe root of the Visual Studio install and combine the paths to findwhat you need.

You can emit different formats for information based on what yourscripts can consume, including plain text, JSON, and XML. Pullrequests may be accepted for other common formats as well.

vswhere is included with the installer as of Visual Studio 2017version 15.2 and later, and can be found at the following location:%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe.

关于c++ - VS 2017 构建工具失败,错误 MSB4019 : The imported project "D:\Microsoft.Cpp.Default.props" was not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50497421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com