本文介绍了为什么 MSBuild 在 C: 中查找 Microsoft.Cpp.Default.props 而不是 c:Program Files (x86)MSBuild?(错误 MSB4019)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行 msbuild 来构建一个 vc2010 项目时,我收到以下错误:

When I run msbuild to build a vc2010 project I get the following error:

error MSB4019: The imported project "C:Microsoft.Cpp.Default.props" was not found.
Confirm that the path in the <Import> declaration is correct, and that the file exists
on disk.

  • msbuild 位于 c:Program File (x86)MSBuild
  • HKLMSOFTWAREWow6432NodeMicrosoftMSBuildToolVersionsV4.0 VCTargetsPath 设置为 $(MSBuildExtensionsPath32)Microsoft.Cppv4.0
  • 当运行 msbuild/verbosity:diag 时,系统显示 MSBuildExtensionsPath32、MSBuildExtensionsPath64、MSBuildExtensionsPath 设置为 Environment at start of build
  • 在 shell 中将 MSBuildExtensionsPath32、MSBuildExtensionsPath64、MSBuildExtensionsPath 设置为环境变量不会导致它们显示为构建开始时的环境
  • 已尝试修复

    • 卸载.net 4.5,修复.net 4.0
    • 在系统变量中设置 MSBuildExtensionsPath32、MSBuildExtensionsPath64、MSBuildExtensionsPath.

    似乎没有正确设置 MSBuildExtensionsPath32 并且设置 MSBuildExtensionsPath 没有帮助

    It appears that MSBuildExtensionsPath32 isn't being set properly and setting MSBuildExtensionsPath doesn't help

    SET MSBuildExtensionsPath="C:Program FilesMSBuild"
    

    如果您有任何想法阻碍了此变量的正确设置,请告诉我.

    Please let me know if you have any ideas what's blocking the proper setting of this variable.

    推荐答案

    对于那些没有遵循 MS 禁令的人(见 Xv 的回答)您仍然可以解决问题.

    For those who didn't follow the MS proscribed order (see Xv's answer) you can still fix the problem.

    MSBuild 使用 VCTargetsPath 来定位默认 cpp 属性,但无法定位,因为注册表缺少此字符串值.

    MSBuild uses the VCTargetsPath to locate default cpp properties but cannot because the registry lacks this String Value.

    检查字符串值

    • 启动注册表编辑器
    • 导航到 HKLMSOFTWAREMicrosoftMSBuildToolsVersions4.0
    • 检查 VCTargetsPath 键.该值应 = "$(MSBuildExtensionsPath32)Microsoft.Cppv4.0"
    • Launch regedit
    • Navigator to HKLMSOFTWAREMicrosoftMSBuildToolsVersions4.0
    • Inspect VCTargetsPath key. The value should = "$(MSBuildExtensionsPath32)Microsoft.Cppv4.0"

    修复

    • 启动 regedit Navigator 到 HKLMSOFTWAREMicrosoftMSBuildToolsVersions4.0
    • 添加字符串值VCTargetsPath
    • 将值设置为$(MSBuildExtensionsPath32)Microsoft.Cppv4.0"

    注意:HKLM代表HKEY_LOCAL_MACHINE.

    这篇关于为什么 MSBuild 在 C: 中查找 Microsoft.Cpp.Default.props 而不是 c:Program Files (x86)MSBuild?(错误 MSB4019)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 08:45