简体   繁体   English

使用MSBuild构建少数项目失败

[英]Building few projects fail with MSBuild

All other C# project files are building with MSBuild scripts. 所有其他C#项目文件都使用MSBuild脚本构建。 But, few C++ related projects are failing with the below error - 但是,很少有与C ++相关的项目因以下错误而失败-

C:\\Program Files (x86)\\MSBuild\\Microsoft.Cpp\\v4.0\\V110\\Microsoft.Cpp.Platform.targets(44,5): error MSB8020: The builds tools for v140 (Platform Toolset = 'v140') cannot be found. C:\\ Program Files(x86)\\ MSBuild \\ Microsoft.Cpp \\ v4.0 \\ V110 \\ Microsoft.Cpp.Platform.targets(44,5):错误MSB8020:v140的构建工具(Platform Toolset ='v140')找不到。 To build using the v140 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". 要使用v140构建工具进行构建,请单击“项目”菜单或右键单击解决方案,然后选择“更新VC ++项目...”。 Install v140 to build using the v140 build tools. 安装v140以使用v140构建工具进行构建。

I am getting the above error when I try to build the project using command prompt and the same error is getting when trying to build using Jenkins. 我在尝试使用命令提示符构建项目时遇到上述错误,而在尝试使用Jenkins进行构建时也遇到了相同的错误。 How should we fix this issue? 我们应该如何解决这个问题?

Solution 1) By creating one System Environment variable - VCTargetsPath with value - C:\\Program Files (x86)\\MSBuild\\Microsoft.Cpp\\v4.0\\V140 , solved building the projects using command prompt on the build server. 解决方案1)通过创建一个系统环境变量VCTargetsPath ,值C:\\Program Files (x86)\\MSBuild\\Microsoft.Cpp\\v4.0\\V140 ,解决了在构建服务器上使用命令提示符构建项目的问题。

But the above solution is not working when trying to build using Jenkins. 但是,当尝试使用Jenkins进行构建时,上述解决方案不起作用。 The below solution resolved the issue. 以下解决方案解决了该问题。

Solution 2) Changed the build scripts to pass this parameter - /p:VCTargetsPath="C:\\Program Files\\MSBuild\\Microsoft.Cpp\\v4.0\\V140" 解决方案2)更改了构建脚本以传递此参数-/ p:VCTargetsPath =“ C:\\ Program Files \\ MSBuild \\ Microsoft.Cpp \\ v4.0 \\ V140”

What's your vs version? 您的vs版本是什么? The C++ project you want to build seems to come from VS2015. 您要构建的C ++项目似乎来自VS2015。

If you are vs2013 or earlier,we can install build tools 2015 to try to solve this issue. 如果您使用的是vs2013或更早版本,我们可以安装构建工具2015来尝试解决此问题。

Note: According to error message, the projects come from vs2015 and sometimes it may cause compatibility issues when we compile projects from higher vs versions. 注意:根据错误消息,项目来自vs2015,有时当我们从更高版本vs编译项目时,可能会导致兼容性问题。 So I prefer to suggest you to update vs to vs2015. 因此,我建议您将vs更新为vs2015。

In addition: Right-click on the project name=>properties=>general=>platform toolset 另外:右键单击项目名称=>属性=>常规=>平台工具集

, then you can find the toolset versions you have, and make sure v140 have installed successfully. ,则可以找到您拥有的工具集版本,并确保已成功安装v140。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM