4

我想创建自定义构建任务,它会调用 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,因此您需要在运行安装的工具之前重新打开命令提示符窗口

4

1 回答 1

1

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

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

于 2018-10-08T01:36:40.550 回答