很容易重现:
- 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
是项目中的 NuGet 服务连接,它使用对我的 GitHub 组织具有完全访问权限的 PAT。
我在日志中看到以下输出
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).
问题似乎出在这一行:
...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 密钥。它仅在 push 命令中使用 api 键...因此在尝试查询源时失败https://nuget.pkg.github.com/ourorg/index.json
我猜这只是 Azure DevOps 中另一个损坏的功能,但希望得到一些确认。
谢谢。