【问题标题】:Jenkins | Node-Gyp error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found詹金斯 | Node-Gyp 错误 MSB8020:找不到 v141 的构建工具(平台工具集 = 'v141')
【发布时间】:2019-10-10 03:28:02
【问题描述】:

我是新手,正在尝试设置新的 Jenkins 构建服务器,并且正在尝试自动化节点插件 api 项目。即使我尝试在 cmd 提示符下运行 node-gyp,我也仅在 Jenkins 服务器上遇到以下问题,它工作正常。

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

我尝试设置环境路径以及在 Gyp 文件中设置正确的 msbuild 路径。但在 Jenkins 中,每次构建都会因上述问题而失败。

在此先感谢您。

【问题讨论】:

    标签: node.js jenkins msbuild node-gyp visual-studio-2019


    【解决方案1】:

    看起来你要构建的项目来自VS2017,它的C++ ToolSet是V141。

    正如您提到的,您使用的是工具集为 V142 的 VS2019。

    修复它:

    1.我们可以将解决方案重新定位到V142 ToolSet,然后VS2019 msbuild工具构建好(在VS2019中打开.sln,右键solutionName并选择重新定位)

    2.另外,您可以选择在VS2019中安装ToolSet V141。

    在 VS2019 中,转到 Tools=>Get Tools and Features=> 为 VS2017 安装 C++ 构建工具:

    (假设您的项目是 X64/X86,而不是 Arm)

    点击修改安装V141 Toolset,新建一个C++工程,右键Project=>properties查看是否安装成功:

    另外,您可能已经安装了 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\。

    【讨论】:

    • 我已经按照你说的进行了上述设置。我的问题是 Build 不是仅通过 Jenkins 生成的。使用正常的 CMD 提示,我可以生成 Build。
    • @Random 相同的 msbuild 路径? 1.好的,请检查您是否设置了VCTargetsPath系统变量,它的值是多少?如果存在,请尝试删除它并检查它是否有帮助。 2.对于jenkins,它看起来类似于this issue,您可以尝试更改脚本并显式设置VCTargetsPath值。
    • 在 vs2019 中安装工具集后的 VCTargetsPath= C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v150\。
    • 它在为 v150 路径设置 VCTargetsPath 后工作。谢谢。
    • @Random 很高兴知道它有帮助!如果我的回答有助于解决您的问题,请您帮忙将其标记为已接受的答案,这对其他有类似问题的成员有好处:)
    猜你喜欢
    • 2019-05-01
    • 1970-01-01
    • 2022-07-05
    • 1970-01-01
    • 2017-09-04
    • 1970-01-01
    • 2021-04-12
    • 2017-10-18
    • 1970-01-01
    相关资源
    最近更新 更多