Building few projects fail with MSBuild

2019-08-20 08:55发布

All other C# project files are building with MSBuild scripts. But, few C++ related projects are failing with the below error -

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. To build using the v140 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install v140 to build using the v140 build tools.

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. How should we fix this issue?

2条回答
Root(大扎)
2楼-- · 2019-08-20 09:25

What’s your vs version? The C++ project you want to build seems to come from VS2015.

If you are vs2013 or earlier,we can install build tools 2015 to try to solve this issue.

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. So I prefer to suggest you to update vs to 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.

查看更多
【Aperson】
3楼-- · 2019-08-20 09:32

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.

But the above solution is not working when trying to build using 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"

查看更多
登录 后发表回答