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

时间:2019-11-17 21:01:07

标签: .net-core azure-devops

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

当前:

运行Command Line Task会显示401:

dotnet tool install -g --add-source=https://pkgs.dev.azure.com/<org-name>/_packaging/Tools/nuget/v3/index.json MyApp
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

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

我目前正在调查Personal Access Tokens (PAT)


以前

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

List of .Net Core commands

日志显示传递给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"

[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"

我尝试了各种参数,但我总是总是看到相同的错误消息:

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.

3 个答案:

答案 0 :(得分:1)

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

您可以使用Command Line task并直接设置dotnet命令:

dotnet tool install -g --add-source=https://pkgs.dev.azure.com/<org-name>/_packaging/Tools/nuget/v3/index.json MyApp

答案 1 :(得分:1)

在尝试访问 nuget 提要之前,您需要添加 nuget 身份验证任务

答案 2 :(得分:1)

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

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

enter image description here