.net core 如何在Azure管道(VST)构建任务中安装和使用dotnet核心工具(CLI)?

.net core 如何在Azure管道(VST)构建任务中安装和使用dotnet核心工具(CLI)?,.net-core,nuget,azure-devops,azure-pipelines-build-task,azure-devops-extensions,.net Core,Nuget,Azure Devops,Azure Pipelines Build Task,Azure Devops Extensions,我想创建自定义构建任务,这将调用dotnet core CLI工具。我曾经获取或安装该工具: import tl = require('vsts-task-lib/task'); async function getLibmanTool() { let libmanExePath = tl.which('libman'); if (!libmanExePath){ console.log("Libman CLI not found. Installing..")

我想创建自定义构建任务,这将调用dotnet core CLI工具。我曾经获取或安装该工具:

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);
}
但是,当我在构建管道中使用该工具时:

我发现以下错误:

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.
看起来,当我在pipleline中安装.NET Core SDK时,它无法找到dotnet工具

问题: 如何安装并安全使用dotnet核心工具?以下是解决方法吗

由于您刚刚安装了.NET Core SDK,因此在运行所安装的工具之前,需要重新打开命令提示符窗口


据我所知,没有任何方法可以避免重新打开CMD


要使其工作,可以在安装包时指定安装路径,然后调用liman.exe的完整路径。或者,如果您想使用“-g”全局安装它,那么到liman.exe的路径应该是“
%USERPROFILE%\.dotnet\tools\liman.exe

这似乎有点疯狂!