在 azure devops 版本上安装并运行自定义 dotnet 工具

Chr*_*sal 9 .net-core azure-devops

我正在尝试构建一个由已发布的 dotnet 核心工具的新版本触发的发布管道。触发器工作正常,但我无法在任务中安装和运行该工具。

现在:

运行命令行任务会导致 401:

dotnet tool install -g --add-source=https://pkgs.dev.azure.com/<org-name>/_packaging/Tools/nuget/v3/index.json MyApp
Run Code Online (Sandbox Code Playgroud)
C:\Program Files\dotnet\sdk\3.0.100\NuGet.targets(123,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/<org-name>/_packaging/Tools/nuget/v3/index.json. [C:\Users\VssAdministrator\AppData\Local\Temp\h0g1c35v.eny\restore.csproj]
C:\Program Files\dotnet\sdk\3.0.100\NuGet.targets(123,5): error :   Response status code does not indicate success: 401 (Unauthorized). [C:\Users\VssAdministrator\AppData\Local\Temp\h0g1c35v.eny\restore.csproj]
The tool package could not be restored.
Tool 'myapp' failed to install. This failure may have been caused by:
* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.
For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool
Run Code Online (Sandbox Code Playgroud)

这让我相信我在这里遗漏了一些东西,使它变得比需要的更复杂,或者以错误的方式思考这个问题。feed中的工具可以在本地安装,所以我相信这是我的发布方法。

我目前正在研究个人访问令牌 (PAT)


之前

如果我使用.Net Core 任务custom选项:

.Net Core 命令列表

日志显示传递给 dotnet.exe 的格式错误的命令:

[command]"C:\Program Files\dotnet\dotnet.exe" "dotnet tool install -g --add-source=https://pkgs.dev.azure.com/<org-name>/_packaging/Tools/nuget/v3/index.json MyApp"
Run Code Online (Sandbox Code Playgroud)

或者

[command]"C:\Program Files\dotnet\dotnet.exe" "tool install -g --add-source=https://pkgs.dev.azure.com/<org-name>/_packaging/Tools/nuget/v3/index.json MyApp"
Run Code Online (Sandbox Code Playgroud)

我尝试过不同的参数,但总是看到相同的错误消息:

Could not execute because the specified command or file was not found.
Possible reasons for this include:
   * You misspelled a built-in dotnet command.
   * You intended to execute a .NET Core program, but dotnet-dotnet tool install -g --add-source=https://pkgs.dev.azure.com/<org-name>/_packaging/Tools/nuget/v3/index.json MyApp does not exist.
   * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Run Code Online (Sandbox Code Playgroud)

spi*_*dyx 8

您的自定义 dotnet 命令被引用并dotnet重复:dotnet.exe" "dotnet tool install ..."因此该命令被误解。

您可以使用命令行任务dotnet直接设置命令:

dotnet tool install -g --add-source=https://pkgs.dev.azure.com/<org-name>/_packaging/Tools/nuget/v3/index.json MyApp
Run Code Online (Sandbox Code Playgroud)


小智 7

使用 .Net Core 任务非常适合我们。

由于 dotnet 命令被引用,因此您需要将 tool 设置为命令并更新为参数。如果需要,可以通过 NuGet Auth 任务提供 NuGet 凭据。

在此输入图像描述