簡體   English   中英

Azure DevOps dotnet build 無權訪問 nuget 包

[英]Azure DevOps dotnet build doesn't have access to nuget packages

在 Azure DevOps 我有我的公司nuget存儲庫。 我創建了一些新的 nuget 包,並將它們包含在我的項目中。 在當地,這些項目運行良好。

當我在 DevOps 上運行dotnet build時出現錯誤,因為存在對 nuget 存儲庫的未經授權的訪問。

在此處輸入圖像描述

[錯誤]C:\Program Files\dotnet\sdk\3.1.202\NuGet.targets(124,5):錯誤:無法加載源https://vs.pkgs.visualstudio.com/Vs/的服務索引_packaging/vs.com/nuget/v3/index.json

響應狀態碼不表示成功:401(未授權)。

C:\Program Files\dotnet\sdk\3.1.202\NuGet.targets(124,5):錯誤:無法加載源https://vs.pkgs.visualstudio.com/Vs/的服務索引.com/nuget/v3/index.json [d:\a\1\s\Payments\Payments.csproj]

C:\Program Files\dotnet\sdk\3.1.202\NuGet.targets(124,5):錯誤:響應狀態碼不表示成功:401(未授權)。 [d:\a\1\s\PiP.Payments.Stripe\PiP.Payments.csproj]

構建失敗。

C:\Program Files\dotnet\sdk\3.1.202\NuGet.targets(124,5):錯誤:無法加載源https://vs.pkgs.visualstudio.com/Vs/的服務索引.com/nuget/v3/index.json [d:\a\1\s\PiP.Payments.Stripe\PiP.Payments.csproj]

C:\Program Files\dotnet\sdk\3.1.202\NuGet.targets(124,5):錯誤:響應狀態碼不表示成功:401(未授權)。

我們之前曾多次遇到此錯誤。 我們總是能夠在dotnet build命令之前使用額外的dotnet restore命令來修復它。

此處的文檔中有一個小提示: https://docs.microsoft.com/en-us/azure/devops/artifacts/nuget/dotnet-exe?view=azure-devops#on-build-machines-and-非交互式場景

在 Azure 管道中,使用 .NET 核心步驟的恢復命令,該命令會自動處理對 Azure 工件源的身份驗證。 否則,請使用 Azure 工件憑據提供程序並使用 VSS_NUGET_EXTERNAL_FEED_ENDPOINTS 環境變量傳入憑據。

這是一個示例 yaml:

    - task: DotNetCoreCLI@2
      displayName: 'Restore Packages'
      inputs:
        command: restore
        projects: 'MyCsproj.csproj'
        vstsFeed: 'voxspan'

    - task: DotNetCoreCLI@2
      displayName: 'Build'
      inputs:
        command: build
        projects: 'MyCsproj.csproj'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM