首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Azure管道无法使用Github包

Azure管道无法使用Github包
EN

Stack Overflow用户
提问于 2020-08-09 08:03:14
回答 2查看 442关注 0票数 4

复制起来非常简单:

代码语言:javascript
复制
          - task: NuGetCommand@2
            displayName: NuGet push
            inputs:
              command: 'push'
              packagesToPush: '$(Pipeline.Workspace)/**/*.nupkg'
              nuGetFeedType: 'external'
              externalFeedCredentials: 'github-packages'
              publishFeedCredentials: 'github-packages'
              allowPackageConflicts: true

github-packages是项目中使用PAT的NuGet服务连接,它具有对我的GitHub组织的完全访问权限。

我在日志中看到以下输出

代码语言:javascript
复制
2020-08-08T23:48:41.3089867Z [command]"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/MSBuild/Current/Bin/msbuild.exe" /version /nologo
2020-08-08T23:48:42.7276911Z Caching tool: NuGet 5.4.0 x64
2020-08-08T23:48:42.7397600Z Found tool in cache: NuGet 5.4.0 x64
2020-08-08T23:48:42.7452624Z Resolved from tool cache: 5.4.0
2020-08-08T23:48:42.7453195Z Using version: 5.4.0
2020-08-08T23:48:42.7465530Z Found tool in cache: NuGet 5.4.0 x64
2020-08-08T23:48:42.8246178Z SYSTEMVSSCONNECTION exists true
2020-08-08T23:48:43.1624000Z SYSTEMVSSCONNECTION exists true
2020-08-08T23:48:43.8522322Z [command]C:\windows\system32\chcp.com 65001
2020-08-08T23:48:43.8632712Z Active code page: 65001
2020-08-08T23:48:44.2527739Z SYSTEMVSSCONNECTION exists true
2020-08-08T23:48:44.2733846Z Detected NuGet version 5.4.0.6315 / 5.4.0+d790b66be476cd901a56bd46ada037162097ee21.d790b66be476cd901a56bd46ada037162097ee21
2020-08-08T23:48:44.2752584Z 1b529ea0-989d-42e8-af13-8ba56ff0e7d8 exists true
2020-08-08T23:48:44.2836605Z [command]C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe sources Add -NonInteractive -Name httpsnugetpkggithubcomourorgindexjson -Source https://nuget.pkg.github.com/ourorg/index.json -ConfigFile d:\a\1\Nuget\tempNuGet_3286.config
2020-08-08T23:48:45.7706128Z Package source with Name: httpsnugetpkggithubcomourorgindexjson added successfully.
2020-08-08T23:48:45.7804645Z Using authentication information for the following URI: https://nuget.pkg.github.com/ourorg/index.json
2020-08-08T23:48:45.8355905Z [command]C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe setapikey *** -NonInteractive -Source httpsnugetpkggithubcomourorgindexjson -ConfigFile d:\a\1\Nuget\tempNuGet_3286.config
2020-08-08T23:48:46.4520785Z The API Key '***' was saved for 'https://nuget.pkg.github.com/ourorg/index.json'.
2020-08-08T23:48:46.4686061Z [command]C:\hostedtoolcache\windows\NuGet\5.4.0\x64\nuget.exe push d:\a\1\Build\M365Management.Console.0.2.83.nupkg -NonInteractive -Source https://nuget.pkg.github.com/ourorg/index.json -ApiKey *** -ConfigFile d:\a\1\Nuget\tempNuGet_3286.config -Verbosity Detailed
2020-08-08T23:48:49.1593595Z Unable to load the service index for source https://nuget.pkg.github.com/ourorg/index.json.
2020-08-08T23:48:49.1594103Z NuGet Version: 5.4.0.6315
2020-08-08T23:48:49.1594906Z   Response status code does not indicate success: 401 (Unauthorized).
2020-08-08T23:48:49.1595523Z Using d:\a\_tasks\NuGetCommand_333b11bd-d341-40d9-afcf-b32d5ce6f23b\2.172.0\CredentialProviderV2\plugins\netfx\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe as a credential provider plugin.
2020-08-08T23:48:49.1596753Z NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source https://nuget.pkg.github.com/ourorg/index.json. ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).

问题似乎出在这一行:

代码语言:javascript
复制
...nuget.exe sources Add -NonInteractive -Name httpsnugetpkggithubcomourorgindexjson -Source https://nuget.pkg.github.com/ourorg/index.json -ConfigFile d:\a\1\Nuget\tempNuGet_3286.config

它将外部提要添加为源,但在添加时不使用服务连接api密钥。由于只使用推流command...and中的api密钥,所以在https://nuget.pkg.github.com/ourorg/index.json查询源失败。

我猜这只是Azure DevOps中的另一个功能残缺不全的部分,但希望能得到一些确认。

谢谢。

EN

回答 2

Stack Overflow用户

发布于 2021-07-12 16:37:16

在您的nuspec文件中,您有存储库元素吗?

代码语言:javascript
复制
<repository type="git" url="https://github.com/yourorganization/YourRepo" />

在执行推送时,请改用ApiKey : ApiKey应该是具有编写包的访问权限的PAT

票数 0
EN

Stack Overflow用户

发布于 2020-08-10 16:00:17

您可能需要使用Basic Authentication作为Nuget服务连接的身份验证方法。在Password字段中使用您的PAT。请看下面的屏幕:

转到项目设置-->管道下的服务连接-->编辑您的Nuget服务连接-->选择Basic Authentication作为身份验证方法-->输入您的UserName-->在Password字段中输入您的PAT

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63321291

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档