VS 2017生成工具失败,错误为MSB4019:导入的项目"D:\ Microsoft.Cpp.Default.props"没找到 [英] VS 2017 Build Tools failing with Error MSB4019: The imported project "D:\Microsoft.Cpp.Default.props" was not found

查看:3530
本文介绍了VS 2017生成工具失败,错误为MSB4019:导入的项目"D:\ Microsoft.Cpp.Default.props"没找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建新的TFS构建服务器,并决定使用VS 2017 Build Tools而不是安装完整版本的VS.当我尝试构建我们的C ++项目时,会引发以下错误:

I'm building a new TFS build server and decided to use the VS 2017 Build Tools instead of installing the full versions of VS. When I attempt to build our C++ projects, it throws the following error:

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

经过数小时的研究,我离解决这个问题越来越近了.我尝试添加以下注册表设置,但没有帮助.

After many hours of research I'm no closer to resolving this issue. I tried adding the following registry settings but it did not help.

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安装程序已损坏.是否有针对此错误的标准修复程序,还是我应该放弃工作并仅安装完整版本?

I'm guessing Microsoft's installer is broken for this product. Is there a standard fix for this error or should I scrap my efforts and simply install the full versions?

在项目文件中,我找到了以下条目:

In the project file, I found this entry:

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

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

So, I guess this means that the variable VSTargetsPath is somehow pointing to the root of the D: drive but I haven't got a clue where that value is being set. Our current build server does not have an environment variable set named VSTargetsPath, but it does have the missing registry entries. It also has full versions of VS installed.

推荐答案

VS 2017 Build Tools失败,错误为MSB4019:找不到导入的项目"D:\ Microsoft.Cpp.Default.props"

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

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

Try to pass VCTargetsPath explicitly as property to msbuild from your build configuration:

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

  1. Edit the build definition for the build.

单击处理"选项卡.

在高级"部分,将"MSBuild参数"设置为包括以下属性:

In the Advanced section, set the MSBuild Arguments to include the following property:

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

保存构建定义.

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

Note: You should change the value of VCTargetsPath to the location of the VCTargets folder.

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

Or pass VisualStudioVersion as property to msbuild:/p:VisualStudioVersion=15.0

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

If you are interesting in the value of $(VCTargetsPath), you can check following threads for some more details:

可以"找不到Visual Studio 2017的注册表项

Visual Studio定位器

这些年来,可以使用注册表项来发现Visual Studio, 但随着部署和可扩展性模型的最新变化, 需要一种新的方法来发现可能不止一次的安装 实例.这些更改有助于更小,更快的默认安装 按需安装其他工作负载和组件.

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

vswhere被设计为可重新分发的单文件可执行文件 可以在构建或部署脚本中使用以查找Visual的位置 Studio-或Visual Studio系列中的其他产品-位于. 例如,如果您知道MSBuild的相对路径,则可以找到 Visual Studio安装的根目录,并合并路径以查找 您需要什么.

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

您可以根据自己的情况发出不同格式的信息 脚本可以使用,包括纯文本,JSON和XML.拉 其他通用格式也可以接受请求.

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

vswhere 版本15.2和更高版本,可以在以下位置找到: %ProgramFiles(x86)%\ Microsoft Visual Studio \ Installer \ vswhere.exe.

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

这篇关于VS 2017生成工具失败,错误为MSB4019:导入的项目"D:\ Microsoft.Cpp.Default.props"没找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆