我想创建自定义构建任务,它会调用 dotnet core CLI 工具。我使用VSTS DevOps Task SDK/node来获取或安装该工具:
import tl = require('vsts-task-lib/task');
async function getLibmanTool() {
let libmanExePath = tl.which('libman');
if (!libmanExePath){
console.log("Libman CLI not found. Installing..")
var dotnet = tl.tool(tl.which('dotnet', true));
await dotnet.arg(['tool', 'install', '-g', 'Microsoft.Web.LibraryManager.Cli']).exec();
}
libmanExePath = tl.which('libman', true); //this line throws, see output
return tl.tool(libmanExePath);
}
但是,当我在 Build Pipeline 中使用该工具时:
我收到以下错误:
Libman CLI not found. Installing..
[command]C:\hostedtoolcache\windows\dncs\2.1.105\x64\dotnet.exe tool install -g Microsoft.Web.LibraryManager.Cli
Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed.
You can invoke the tool using the following command: libman
Tool 'microsoft.web.librarymanager.cli' (version '1.0.163') was successfully installed.
##[error]Unable to locate executable file: 'libman'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
看起来当我在管道中安装 .NET Core SDK 时,找不到 dotnet 工具
问题:
如何安装并安全使用 dotnet core 工具?有什么方法可以解决以下问题吗?
由于您刚刚安装了 .NET Core SDK,因此您需要在运行安装的工具之前重新打开命令提示符窗口