如何使用 dotnet cli 安装“Node JS 工具”

BeF*_*oRE 7 .net msbuild continuous-integration node.js gitlab

我们正在构建一个 ASP.NET Core 解决方案,并且最近向该解决方案添加了一个 NodeJS 项目。现在,当我们运行 CI 时,会出现以下错误:

error MSB4019: The imported project "/usr/share/dotnet/sdk/3.1.201/Microsoft/VisualStudio/v16.0/Node.js Tools/Microsoft.NodejsToolsV2.targets" was not found. Confirm that the expression in the Import declaration "/usr/share/dotnet/sdk/3.1.201/Microsoft/VisualStudio/v16.0/Node.js Tools/Microsoft.NodejsToolsV2.targets" is correct, and that the file exists on disk.
Run Code Online (Sandbox Code Playgroud)

这是有道理的,因为我们在任何时候都没有安装“NodeJS 工具”,但我们找不到如何安装这些工具。如何使用 dotnet cli 安装 NodeJS 工具?

Mar*_*ich 4

CLIdotnet无法构建这些项目,因为这些项目所需的工具是 Visual Studio 的一部分,而不是 .NET Core 发行版或 .NET Sdk 支持的工作负载。

虽然您仍然可以dotnet在 .NET Core/Standard csproj 文件上使用 CLI,但不能在包含 CLI 不支持的项目的解决方案文件上使用它。

但是,您可以msbuild.exe在所有项目上使用 Visual Studio 安装中的命令(建议使用 VS 开发人员命令提示符),例如:

dotnet build foo.sln=>msbuild -restore foo.sln

  • OP 并不是在寻找 NodeJS 本身,而是在寻找名为“NodeJS 工具”的 Visual Studio 工作负载的 MSBuild 目标/任务部分。这些需要成为 CLI / SDK 发行版本身的一部分(请参阅问题中的“sdk/3.1.201”文件夹),或者本身需要重新架构为 MSBuild SDK,可以单独安装 (2认同)