[英]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.