我是新手,正在尝试设置新的Jenkins Build服务器,并且正在尝试自动化节点插件API项目。我仅在Jenkins服务器上面临以下问题,即使我尝试在cmd提示符下运行node-gyp时,也可以正常工作。
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\jenkins_builds\Reporter-Backend\workspace\build\copy_binary.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\jenkins_builds\Reporter-Backend\workspace\node_modules\node-addon-api\src\nothing.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
Node version v10.15.3
Node-Gyp v4.0.0
Jenkins v2.164.3
Visual Studio 2019
我尝试设置envirmont路径以及在Gyp文件中设置正确的msbuild路径。但是在Jenkins中,每次出现上述问题,构建都会失败。
先谢谢您
答案 0 :(得分:0)
看起来您要构建的项目来自VS2017,其C ++工具集为V141。
正如您提到的,您使用工具集为V142的VS2019。
要修复它:
1。我们可以将解决方案重新定位到V142 ToolSet,然后VS2019 msbuild工具将其很好地构建(在VS2019中打开.sln,右键单击solutionName并选择重新定位)
2。此外,您还可以选择在VS2019中安装ToolSet V141。
在VS2019中,转到Tools => Get Tools and Features =>为VS2017安装C ++构建工具:
单击“修改”以安装V141工具集,并创建一个新的C ++项目,右键单击“项目” =>“属性”以检查是否成功安装了ToolSet v141:
此外,您可能已经安装了ToolSet,并且由于错误的msbuild路径或参数而导致错误。
因此请确保VS2019的msbuild路径为:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe
更新:
在vs2019中安装工具集后,尝试设置VCTargetsPath:VCTargetsPath = C:\ Program Files(x86)\ Microsoft Visual Studio \ 2019 \ Community \ MSBuild \ Microsoft \ VC \ v150 \。