如何在 Azure Pipelines (VSTS) 构建任务中安装和使用 dotnet 核心工具 (CLI)?
How to install and use dotnet core tool (CLI) in Azure Pipelines (VSTS) Build Task?
我想创建自定义构建任务,它会调用 dotnet 核心 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.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 核心工具?以下是解决方法吗?
Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed
据我所知,没有任何解决方法可以避免重新打开 CMD。
要使其正常工作,您可以在安装包时指定安装路径,然后调用 liman.exe 的完整路径。或者如果你想用“-g”全局安装它,那么liman.exe的路径应该是“%USERPROFILE%\.dotnet\tools\liman.exe
”。
我想创建自定义构建任务,它会调用 dotnet 核心 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.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 核心工具?以下是解决方法吗?
Since you just installed the .NET Core SDK, you will need to reopen the Command Prompt window before running the tool you installed
据我所知,没有任何解决方法可以避免重新打开 CMD。
要使其正常工作,您可以在安装包时指定安装路径,然后调用 liman.exe 的完整路径。或者如果你想用“-g”全局安装它,那么liman.exe的路径应该是“%USERPROFILE%\.dotnet\tools\liman.exe
”。