【发布时间】:2020-06-03 09:06:36
【问题描述】:
2020 年 2 月 20 日更新
总结
Azure DevOps 管道构建无法从我们在 Artifacts 下的私有源中找到 NuGet 包。
我们的 Azure DevOps 环境
在 Azure 中,我们有我们的公司“空间”:dev.azure.com/OurCompany
在这之下,我们有多个项目,例如,想象一下这三个:
- 绿色:包含特定类型的应用程序
- 蓝色:这包含不同类型的应用程序
- 红色:这包含我们的“通用”帮助代码
红色
RED 持有我们所有常见的帮助代码都是 GREEN 和 BLUE 应用程序使用的 DLL。这些以 NuGet 包的形式提供。
在 RED 的 Artifacts 下,我们看到了一个名为“OurCompany”的“组织范围的提要”。我们知道我们不能使用它,因为这些 NuGet 包需要对 OurCompany 中的每个人都可用,这意味着不仅在 Azure 上,而且在我们公司网络中的桌面计算机上(我们运行 Visual Studio 的地方)。我认为“组织范围的提要”不会暴露在我们的企业网络中。
因此,我们在 RED 的 Artifacts 下创建了一个新的 Feed。当我查看权限时,我看到以下条目:
- {我}:(所有者)
- [OurCompany]\Project Collection 管理员:(所有者)
- [RED]\项目管理员:(所有者)
- RED 构建服务(OurCompany):(贡献者)
- 项目集合构建服务(OurCompany):(贡献者)
- [RED]\Contributors(贡献者)
公司
所以,回到 Corporate 中,我们将 NuGet 包源添加到 Visual Studio,然后它可以从 Azure 中提取 NuGet 包。
绿色和蓝色
这里有我们的产品。我们创建一个构建管道并添加一个 NuGet 恢复步骤:
- task: NuGetCommand@2
displayName: 'Restore for Our Application'
inputs:
command: 'restore'
restoreSolution: '**/*.sln'
feedsToUse: 'select'
vstsFeed: '{Guid1}/{Guid2}'
当我们从下拉列表中挑选 Azure Artifacts 提要时,这两个 Guid 已被填写。
绿色或蓝色 NuGet 还原失败
这就是我们遇到问题的地方。当 NuGet 还原步骤执行时,它会失败并显示以下消息:
Unable to find version 'nnnn.n.n' of package 'TheNuGetPackage'.
日志输出很大,但显着的行似乎是:
2020-02-18T18:36:35.2838118Z [command]C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe sources Add -NonInteractive -Name {Guid2} -Source https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json
-ConfigFile d:\a\1\Nuget\tempNuGet_356.config 2020-02-18T18:36:35.7513495Z Package source with Name: {Guid2} added successfully. 2020-02-18T18:36:41.1671856Z [CredentialProvider.183638]Command-line v0.1.20+a5d37185a1a95acb4f0g997b9c23cab99508: "d:\a\_tasks\NuGetCommand_333b11bd-d341-40d9-bdbd-b32d5ce6f23b\2.164.0\CredentialProviderV2\plugins\netfx\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe"
-Plugin 2020-02-18T18:36:41.1673979Z [CredentialProvider]Handling 'Request' 'GetAuthenticationCredentials'. Time elapsed in ms: 3 - Payload: {"Uri":"https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json","IsRetry":false,"IsNonInteractive":true,"CanShowDialog":true} 2020-02-18T18:36:41.1674299Z [CredentialProvider]Handling auth request, Uri: https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json, IsRetry: False, IsNonInteractive: True, CanShowDialog: True 2020-02-18T18:36:41.1674465Z [CredentialProvider]URI: https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json 2020-02-18T18:36:41.1674818Z [CredentialProvider]Skipping NuGetCredentialProvider.CredentialProviders.VstsBuildTaskServiceEndpoint.VstsBuildTaskServiceEndpointCredentialProvider, cannot provide credentials for https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json 2020-02-18T18:36:41.1675261Z [CredentialProvider]VstsBuildTaskCredentialProvider - https://dev.azure.com/OurCompany/ 2020-02-18T18:36:41.1675425Z [CredentialProvider]VstsBuildTaskCredentialProvider - https://pkgs.dev.azure.com/OurCompany/ 2020-02-18T18:36:41.1675722Z [CredentialProvider]VstsBuildTaskCredentialProvider - https://pkgs.dev.azure.com/OurCompany/ 2020-02-18T18:36:41.1676021Z [CredentialProvider]VstsBuildTaskCredentialProvider - https://pkgs.dev.azure.com/OurCompany/ 2020-02-18T18:36:41.1676161Z [CredentialProvider]VstsBuildTaskCredentialProvider - Matched prefix: https://pkgs.dev.azure.com/OurCompany/ 2020-02-18T18:36:41.1676330Z [CredentialProvider]VstsBuildTaskCredentialProvider - Found credentials for endpoint https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json 2020-02-18T18:36:41.1680820Z https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json: Unable to load the service index for source https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json. 2020-02-18T18:36:41.1680996Z Response status code does not indicate success: 404 (Not Found - VS800075: The project with id 'vstfs:///Classification/TeamProject/{Guid1}' does not exist, or you do not have permission to access it. (DevOps Activity ID: 0628EDE7-6E7E-465D-A6AE-7B6B0AA065D2)).
这对我来说似乎是一个权限问题。但奇怪的是,当我们没有使用它的权限时,在创建管道构建 YAML 时可以发现 RED 中的 Artifact Feed。
我确实尝试在 RED 中为 Feed 添加权限。单击“添加用户/组”。我找到以下内容并将它们添加为读者或贡献者,但没有成功。
- [GREEN]\绿队
- 绿色构建服务
所以:
- 我是不是走错了路?如果是这样,我应该做什么(我认为我已经非常严格地遵循了 Azure DevOps 说明)
- 我这样做是否正确?如果有,我错过了什么?
更新 #1
来自恢复步骤的详细错误消息
https://api.nuget.org/v3/index.json: 包 'Package1.nnnn.n.n' 是 在源“https://api.nuget.org/v3/index.json”上找不到。
https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json: 无法加载源的服务索引 https://pkgs.dev.azure.com/OurCompany/{Guid1}/_packaging/{Guid2}/nuget/v3/index.json。 响应状态码不表示成功:404(未找到- VS800075: id 的项目 'vstfs:///Classification/TeamProject/{Guid1}' 不存在,或者您 无权访问它。 (DevOps 活动 ID:{Guid}))。
【问题讨论】:
-
注意到您cross-posted this question。因为它在这里很受欢迎(赞成,回答),我不会删除这个副本,但是as per the general rules of the Stack Exchange network你真的应该删除旧帖子。
-
这个问题首先发布在 DevOps.SE 上,所以 SO 版本是交叉发布的……(应该删除或迁移)。
标签: azure-devops azure-pipelines devops nuget-package-restore azure-artifacts