When I run msbuild to build a vc2010 project I get the following error:
当我运行msbuild构建一个vc2010项目时,我得到以下错误:
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 located c:\Program File (x86)\MSBuild
- msbuild定位于c:\程序文件(x86)\ msbuild。
- HKLM\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolVersions\V4.0 VCTargetsPath set to $(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\
- HKLM\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ V4.0 VCTargetsPath设置为$(MSBuildExtensionsPath32)\Microsoft.Cpp\ V4.0 \。
- when running msbuild /verbosity:diag as good system shows MSBuildExtensionsPath32, MSBuildExtensionsPath64, MSBuildExtensionsPath set as Environment at start of build
- 当运行msbuild /verbosity时:diag作为良好的系统显示MSBuildExtensionsPath32, MSBuildExtensionsPath64, MSBuildExtensionsPath设置为环境开始构建。
- setting MSBuildExtensionsPath32, MSBuildExtensionsPath64, MSBuildExtensionsPath set as environment variables in shell doesn't cause them to show as Environment at start of build
- 设置MSBuildExtensionsPath32、MSBuildExtensionsPath64、MSBuildExtensionsPath作为环境变量在shell中并不会导致它们在构建开始时显示为环境。
Fixes Attempted
尝试修复
- Uninstalled .net 4.5, repaired .net 4.0
- 卸载。net 4.5,修复。net 4.0。
- Set MSBuildExtensionsPath32, MSBuildExtensionsPath64, MSBuildExtensionsPath in system variables.
- 在系统变量中设置MSBuildExtensionsPath32, MSBuildExtensionsPath64, MSBuildExtensionsPath。
It appears that MSBuildExtensionsPath32 isn't being set properly and setting MSBuildExtensionsPath doesn't help
似乎MSBuildExtensionsPath32没有被正确设置并设置MSBuildExtensionsPath没有帮助。
SET MSBuildExtensionsPath="C:\Program Files\MSBuild"
Please let me know if you have any ideas what's blocking the proper setting of this variable.
请告诉我你是否有任何想法阻止这个变量的正确设置。
11 个解决方案
#1
46
I got this problem when publishing a cocos2d-x application using their command line tool, which calls MSBuild. I'm using Win 7 64-bit, VS2013 express, cocos2d-x version 3.3, .NET Framework 4.5 installed.
我在使用他们的命令行工具(调用MSBuild)发布cocos2d-x应用程序时遇到了这个问题。我使用Win 7 64位,VS2013 express, cocos2d-x版本3.3,. net Framework 4.5安装。
I fixed the problem by setting the following before running the cocos.py publish command:
在运行cocos之前,我设置了以下问题来解决这个问题。py发布命令:
SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120
#2
35
For those who didn't follow the MS proscribed order (see Xv's answer) you can still fix the problem.
对于那些没有按规定顺序执行的人(参见Xv的答案),你仍然可以解决这个问题。
MSBuild uses the VCTargetsPath
to locate default cpp properties but cannot because the registry lacks this String Value.
MSBuild使用VCTargetsPath来定位默认的cpp属性,但不能因为注册表缺少这个字符串值。
Check for the String Value
检查字符串值。
- Launch regedit
- 启动注册表编辑器
- Navigator to
HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
- 导航器微软HKLM \ SOFTWARE \ \ MSBuild \ ToolsVersions \ 4.0
- Inspect
VCTargetsPath
key. The value should = "$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\
" - 检查VCTargetsPath关键。该值应该= "$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\"
To fix
修复
- Launch regedit Navigator to
HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
- 启动regedit导航到HKLM\软件\微软\MSBuild\ToolsVersions\4.0。
- Add String Value
VCTargetsPath
- 添加字符串值VCTargetsPath
- Set Value to "
$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\
" - 值设置为“$(MSBuildExtensionsPath32)\ Microsoft.Cpp \ v4.0 \”
Note: HKLM
stands for HKEY_LOCAL_MACHINE
.
注:HKLM代表HKEY_LOCAL_MACHINE。
#3
12
Installing Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1 fixed the MSB4019
errors that I was getting building on Windows7 x64.
安装microsoftvisualc++ 2010服务包1编译器更新为Windows SDK 7.1修复了我在Windows7 x64上构建的MSB4019错误。
The readme of that update states that the recommended order is
该更新的readme说明了建议的顺序。
- Visual Studio 2010
- Visual Studio 2010
- Windows SDK 7.1
- Windows SDK 7.1
- Visual Studio 2010 SP1
- Visual Studio 2010 SP1
- Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
- Visual c++ 2010 SP1编译器更新为Windows SDK 7.1。
#4
9
I have had the same problem recently and after installing different packages in different order it was just getting very messy. Then I have found this repo - https://github.com/felixrieseberg/windows-build-tools
我最近遇到了同样的问题,在安装不同的包之后,它变得非常混乱。然后我找到了这个repo - https://github.com/felixrieseberg/windows-build-tools。
npm install --global windows-build-tools
全球windows-build-tools npm安装——
It installs Python & VS Build tools that are required to compile most node modules. It worked a treat!
它安装Python和VS构建工具,这些工具需要编译大多数节点模块。这工作把!
#5
6
On 64-bit systems, MSBuild defaults to the following properties (where C: is SystemDrive):
在64位系统上,MSBuild默认为以下属性(其中C:为SystemDrive):
MSBuildExtensionsPath = C:\Program Files (x86)\MSBuild
MSBuildExtensionsPath32 = C:\Program Files (x86)\MSBuild
MSBuildExtensionsPath64 = C:\Program Files\MSBuild
If it doesn't, it means you either have some custom third-party overrides targets installed, or your MSBuild installation is corrupted.
如果没有,这意味着您可能有一些自定义的第三方覆盖目标安装,或者您的MSBuild安装已经损坏。
Things to try:
尝试的东西:
- Repair .NET installation
- 修复安装。net
- Apply latest Visual Studio Service Pack
- 应用最新的Visual Studio服务包。
- Set
MSBuildExtensionsPath
manually as above (note thex86
part on 64-bit machines) - 手动设置MSBuildExtensionsPath(请注意64位机器上的x86部分)
#6
2
Installing Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1 worked for me. However, I experienced issues with the update because I already had VS 2010 and VS 2010 SP1 installed. As mentioned by Xv above, the readme.htm file contains solutions for the most common installation issues in the "Known Issues" section. I would follow the instructions in the readme.htm and reboot your machine after each troubleshooting attempt because some installs write to your registry.
安装微软Visual c++ 2010服务包1编译器更新为Windows SDK 7.1为我工作。然而,我遇到了更新的问题,因为我已经安装了VS 2010和VS 2010 SP1。如上文所述,自述。htm文件包含“已知问题”部分中最常见的安装问题的解决方案。我会按照自述的指示行事。在每次故障排除尝试之后,重新启动您的机器,因为有些安装会写入到您的注册表中。
#7
1
MSBuild in an independent build tool that is frequently bundled with other tools. It may have been installed on your computer with .NET (older versions), Visual Studio (newer versions), or even Team Foundation Build.
MSBuild在一个独立的构建工具中,经常与其他工具绑定。它可能已经安装在您的计算机上,有。net(旧版本),Visual Studio(更新版本),甚至团队基础构建。
MSBuild needs configuration files, compilers, etc (a ToolSet) that matches the version of Visual Studio or TFS that will use it, as well as the version of .NET against which source code will be compiled.
MSBuild需要配置文件、编译器等(一种工具集),它与将使用它的Visual Studio或TFS的版本相匹配,以及用于编译源代码的. net版本。
Depending on how MSBuild was installed, the configuration files may be in one or more of these paths.
根据MSBuild的安装方式,配置文件可能位于其中一个或多个路径中。
- C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\
- C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \
- C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\
- C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \ V120 \
- C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\
- C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \ V140 \
As described in other answers, a registry item and/or environmental variable point must to the ToolSet path.
如其他答案所述,注册表项和/或环境变量必须指向工具集路径。
- The VCTargetsPath key under HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
- 在HKLM\软件\微软\MSBuild\ToolsVersions\4.0中使用VCTargetsPath键。
- The VCTargetsPath environmental variable.
- VCTargetsPath环境变量。
Occasionally, an operation like installing a tool will leave the registry and/or environmental variable set incorrectly. The other answers are all variations on fixing them.
有时,像安装工具这样的操作会使注册表和/或环境变量设置不正确。其他的答案都是关于修复它们的。
The only thing I have to add is the environmental variable didn't work for me when I left off the trailing \
我唯一需要补充的是,当我离开后,环境变量对我不起作用。
#8
0
I came across this error by writing a Build script that would put MSBuild on the %PATH% after recursively digging through the C:\Windows\Microsoft.NET folder for any found MSBuild.exe files. The last found hit was the directory that was put on the path. Since the dir
command would hit the Framework64
folder after Framework
I was getting one of the 64bit MSBuilds put on my path. I was trying to build a Visual Studio 2010 solution and wound up altering my search string from C:\Windows\Microsoft.NET
to C:\Windows\Microsoft.NET\Framework
so that I would wind up with a 32bit MSBuild.exe. Now my solution file builds.
我编写了一个构建脚本,它将在通过c:windowsmicrosoft递归地挖掘后,将MSBuild放在%PATH%上,从而发现了这个错误。NET文件夹,用于任何发现的MSBuild。exe文件。最后发现的hit是放在path上的目录。由于dir命令将在框架之后到达Framework64文件夹,所以我将在路径上安装一个64位msbuild。我试图建立一个Visual Studio 2010的解决方案,改变我从C:\Windows\Microsoft.的搜索字符串网C:\Windows\Microsoft.这样我就能得到一个32位的MSBuild.exe。现在我的解决方案文件构建。
#9
0
I just added VCTargetsPath={c:\...}
as an environment variable to my Hudson job.
我只是添加VCTargetsPath = { c:\…}作为我的Hudson任务的环境变量。
#10
0
For the record, the file Microsoft.Cpp.Default.props
can modify the env var VCTargetsPath
and make subsequent usages of that var incorrect. I had that problem and solved it by setting VCTargetsPath10
and VCTargetsPath11
to the same value than VCTargetsPath
.
对于记录,文件Microsoft.Cpp.Default。道具可以修改env var VCTargetsPath,并使该var的后续用法不正确。我有这个问题,并通过将VCTargetsPath10和VCTargetsPath11设置为与VCTargetsPath相同的值来解决它。
This should be adapted according to the VS version you are using.
这应该根据您正在使用的VS版本进行调整。
#11
0
I'm seeing this in a VS2017 environment. My build script calls VsDevCmd.bat
first, and to solve this problem I set the VCTargetsPath
environment variable after VsDevCmd
and before calling MSBuild:
我在VS2017的环境中看到了这一点。我的构建脚本调用VsDevCmd。首先,为了解决这个问题,我在VsDevCmd和调用MSBuild之前设置了VCTargetsPath环境变量:
set VCTargetsPath=%VCIDEInstallDir%VCTargets
#1
46
I got this problem when publishing a cocos2d-x application using their command line tool, which calls MSBuild. I'm using Win 7 64-bit, VS2013 express, cocos2d-x version 3.3, .NET Framework 4.5 installed.
我在使用他们的命令行工具(调用MSBuild)发布cocos2d-x应用程序时遇到了这个问题。我使用Win 7 64位,VS2013 express, cocos2d-x版本3.3,. net Framework 4.5安装。
I fixed the problem by setting the following before running the cocos.py publish command:
在运行cocos之前,我设置了以下问题来解决这个问题。py发布命令:
SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120
#2
35
For those who didn't follow the MS proscribed order (see Xv's answer) you can still fix the problem.
对于那些没有按规定顺序执行的人(参见Xv的答案),你仍然可以解决这个问题。
MSBuild uses the VCTargetsPath
to locate default cpp properties but cannot because the registry lacks this String Value.
MSBuild使用VCTargetsPath来定位默认的cpp属性,但不能因为注册表缺少这个字符串值。
Check for the String Value
检查字符串值。
- Launch regedit
- 启动注册表编辑器
- Navigator to
HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
- 导航器微软HKLM \ SOFTWARE \ \ MSBuild \ ToolsVersions \ 4.0
- Inspect
VCTargetsPath
key. The value should = "$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\
" - 检查VCTargetsPath关键。该值应该= "$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\"
To fix
修复
- Launch regedit Navigator to
HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
- 启动regedit导航到HKLM\软件\微软\MSBuild\ToolsVersions\4.0。
- Add String Value
VCTargetsPath
- 添加字符串值VCTargetsPath
- Set Value to "
$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\
" - 值设置为“$(MSBuildExtensionsPath32)\ Microsoft.Cpp \ v4.0 \”
Note: HKLM
stands for HKEY_LOCAL_MACHINE
.
注:HKLM代表HKEY_LOCAL_MACHINE。
#3
12
Installing Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1 fixed the MSB4019
errors that I was getting building on Windows7 x64.
安装microsoftvisualc++ 2010服务包1编译器更新为Windows SDK 7.1修复了我在Windows7 x64上构建的MSB4019错误。
The readme of that update states that the recommended order is
该更新的readme说明了建议的顺序。
- Visual Studio 2010
- Visual Studio 2010
- Windows SDK 7.1
- Windows SDK 7.1
- Visual Studio 2010 SP1
- Visual Studio 2010 SP1
- Visual C++ 2010 SP1 Compiler Update for the Windows SDK 7.1
- Visual c++ 2010 SP1编译器更新为Windows SDK 7.1。
#4
9
I have had the same problem recently and after installing different packages in different order it was just getting very messy. Then I have found this repo - https://github.com/felixrieseberg/windows-build-tools
我最近遇到了同样的问题,在安装不同的包之后,它变得非常混乱。然后我找到了这个repo - https://github.com/felixrieseberg/windows-build-tools。
npm install --global windows-build-tools
全球windows-build-tools npm安装——
It installs Python & VS Build tools that are required to compile most node modules. It worked a treat!
它安装Python和VS构建工具,这些工具需要编译大多数节点模块。这工作把!
#5
6
On 64-bit systems, MSBuild defaults to the following properties (where C: is SystemDrive):
在64位系统上,MSBuild默认为以下属性(其中C:为SystemDrive):
MSBuildExtensionsPath = C:\Program Files (x86)\MSBuild
MSBuildExtensionsPath32 = C:\Program Files (x86)\MSBuild
MSBuildExtensionsPath64 = C:\Program Files\MSBuild
If it doesn't, it means you either have some custom third-party overrides targets installed, or your MSBuild installation is corrupted.
如果没有,这意味着您可能有一些自定义的第三方覆盖目标安装,或者您的MSBuild安装已经损坏。
Things to try:
尝试的东西:
- Repair .NET installation
- 修复安装。net
- Apply latest Visual Studio Service Pack
- 应用最新的Visual Studio服务包。
- Set
MSBuildExtensionsPath
manually as above (note thex86
part on 64-bit machines) - 手动设置MSBuildExtensionsPath(请注意64位机器上的x86部分)
#6
2
Installing Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1 worked for me. However, I experienced issues with the update because I already had VS 2010 and VS 2010 SP1 installed. As mentioned by Xv above, the readme.htm file contains solutions for the most common installation issues in the "Known Issues" section. I would follow the instructions in the readme.htm and reboot your machine after each troubleshooting attempt because some installs write to your registry.
安装微软Visual c++ 2010服务包1编译器更新为Windows SDK 7.1为我工作。然而,我遇到了更新的问题,因为我已经安装了VS 2010和VS 2010 SP1。如上文所述,自述。htm文件包含“已知问题”部分中最常见的安装问题的解决方案。我会按照自述的指示行事。在每次故障排除尝试之后,重新启动您的机器,因为有些安装会写入到您的注册表中。
#7
1
MSBuild in an independent build tool that is frequently bundled with other tools. It may have been installed on your computer with .NET (older versions), Visual Studio (newer versions), or even Team Foundation Build.
MSBuild在一个独立的构建工具中,经常与其他工具绑定。它可能已经安装在您的计算机上,有。net(旧版本),Visual Studio(更新版本),甚至团队基础构建。
MSBuild needs configuration files, compilers, etc (a ToolSet) that matches the version of Visual Studio or TFS that will use it, as well as the version of .NET against which source code will be compiled.
MSBuild需要配置文件、编译器等(一种工具集),它与将使用它的Visual Studio或TFS的版本相匹配,以及用于编译源代码的. net版本。
Depending on how MSBuild was installed, the configuration files may be in one or more of these paths.
根据MSBuild的安装方式,配置文件可能位于其中一个或多个路径中。
- C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\
- C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \
- C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\
- C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \ V120 \
- C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\
- C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \ V140 \
As described in other answers, a registry item and/or environmental variable point must to the ToolSet path.
如其他答案所述,注册表项和/或环境变量必须指向工具集路径。
- The VCTargetsPath key under HKLM\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0
- 在HKLM\软件\微软\MSBuild\ToolsVersions\4.0中使用VCTargetsPath键。
- The VCTargetsPath environmental variable.
- VCTargetsPath环境变量。
Occasionally, an operation like installing a tool will leave the registry and/or environmental variable set incorrectly. The other answers are all variations on fixing them.
有时,像安装工具这样的操作会使注册表和/或环境变量设置不正确。其他的答案都是关于修复它们的。
The only thing I have to add is the environmental variable didn't work for me when I left off the trailing \
我唯一需要补充的是,当我离开后,环境变量对我不起作用。
#8
0
I came across this error by writing a Build script that would put MSBuild on the %PATH% after recursively digging through the C:\Windows\Microsoft.NET folder for any found MSBuild.exe files. The last found hit was the directory that was put on the path. Since the dir
command would hit the Framework64
folder after Framework
I was getting one of the 64bit MSBuilds put on my path. I was trying to build a Visual Studio 2010 solution and wound up altering my search string from C:\Windows\Microsoft.NET
to C:\Windows\Microsoft.NET\Framework
so that I would wind up with a 32bit MSBuild.exe. Now my solution file builds.
我编写了一个构建脚本,它将在通过c:windowsmicrosoft递归地挖掘后,将MSBuild放在%PATH%上,从而发现了这个错误。NET文件夹,用于任何发现的MSBuild。exe文件。最后发现的hit是放在path上的目录。由于dir命令将在框架之后到达Framework64文件夹,所以我将在路径上安装一个64位msbuild。我试图建立一个Visual Studio 2010的解决方案,改变我从C:\Windows\Microsoft.的搜索字符串网C:\Windows\Microsoft.这样我就能得到一个32位的MSBuild.exe。现在我的解决方案文件构建。
#9
0
I just added VCTargetsPath={c:\...}
as an environment variable to my Hudson job.
我只是添加VCTargetsPath = { c:\…}作为我的Hudson任务的环境变量。
#10
0
For the record, the file Microsoft.Cpp.Default.props
can modify the env var VCTargetsPath
and make subsequent usages of that var incorrect. I had that problem and solved it by setting VCTargetsPath10
and VCTargetsPath11
to the same value than VCTargetsPath
.
对于记录,文件Microsoft.Cpp.Default。道具可以修改env var VCTargetsPath,并使该var的后续用法不正确。我有这个问题,并通过将VCTargetsPath10和VCTargetsPath11设置为与VCTargetsPath相同的值来解决它。
This should be adapted according to the VS version you are using.
这应该根据您正在使用的VS版本进行调整。
#11
0
I'm seeing this in a VS2017 environment. My build script calls VsDevCmd.bat
first, and to solve this problem I set the VCTargetsPath
environment variable after VsDevCmd
and before calling MSBuild:
我在VS2017的环境中看到了这一点。我的构建脚本调用VsDevCmd。首先,为了解决这个问题,我在VsDevCmd和调用MSBuild之前设置了VCTargetsPath环境变量:
set VCTargetsPath=%VCIDEInstallDir%VCTargets