NuGet 推送导致 TFS 构建和 TFS 服务器本身出现 401 未授权错误
NuGet Push Results in 401 Unauthorized Error within TFS Build and on TFS Server Itself
NuGet 推送导致 TFS 构建和 TFS 服务器本身出现 401 未经授权的错误
我们正在从 BitBucket、Jenkins 和 Nexus 过渡到 TFS 2018 以容纳我们的 Git 存储库、持续集成我们的 C# 代码并存储我们的构建工件。我们正在我们的 TFS 服务器上添加我们的第一个构建定义,并且我们的构建定义(如下)成功,直到我们进入 NuGet 推送步骤。
- 获取源代码 - 从同一 TFS 服务器克隆 Git 存储库
- NuGet 工具安装程序(版本 0.*) - 安装 NuGet 4.3.0
- 下载文件(版本 1.*) - 下载要在构建过程中使用的可执行 JAR(有关详细信息,请参见底部)。
- NuGet(版本 2.*) - 在我们的解决方案中恢复 NuGet 包
- Powershell(版本 1.*) - 调用 JAR 以在我们的
.nuspec
文件中为 NuGet 打包步骤填充依赖项。
- Powershell(版本 1.*) - 调用 JAR 以增加修订版本号(有关更多信息,请参见底部)。
- MSBuild(版本 1.*) - 构建解决方案
- Powershell(版本 1.*) - 调用 JAR 以增加内部版本号和次要版本号(有关更多信息,请参见底部)。
- NuGet(版本 1.*) - 打包 NuGet 包
- NuGet(版本 1.*) - 将 NuGet 包推送到 TFS 上的 NuGet 提要
- Powershell(版本 1.*) - 调用 JAR 将最终版本号存储在服务器上,以便在未来的构建中使用(更多信息见底部) .
当我们到达推送 NuGet 包的第 10 步时,我们收到以下错误,即使项目构建服务是 NuGet 源上的 "Owner",并且构建的项目授权范围定义设置为 "Project Collection."
2018-02-01T15:55:20.2291785Z ##[section]Starting: NuGet push
2018-02-01T15:55:20.2291785Z ==============================================================================
2018-02-01T15:55:20.2291785Z Task : NuGet
2018-02-01T15:55:20.2291785Z Description : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet.
2018-02-01T15:55:20.2291785Z Version : 2.0.7
2018-02-01T15:55:20.2291785Z Author : Microsoft Corporation
2018-02-01T15:55:20.2291785Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2018-02-01T15:55:20.2291785Z ==============================================================================
2018-02-01T15:55:20.9633816Z [command]C:\WINDOWS\system32\chcp.com 65001
2018-02-01T15:55:21.0259411Z Active code page: 65001
2018-02-01T15:55:21.0416108Z SYSTEMVSSCONNECTION exists true
2018-02-01T15:55:21.0727651Z Detected NuGet version 4.3.0.4406 / 4.3.0
2018-02-01T15:55:21.1509681Z Saving NuGet.config to a temporary config file.
2018-02-01T15:55:21.1668061Z ##[warning]No package sources were found in the NuGet.config file at C:\agent\_work\Nuget\tempNuGet_178.config
2018-02-01T15:55:21.1821145Z [command]C:\agent\_work\_tool\NuGet.3.0\x64\nuget.exe push C:\agent\_work\a\{name_of_our_nuget_package}.nupkg -NonInteractive -Source https://{tfs_server_location}/Mobile%20Applications/_packaging/a4a3b7fe-b530-4e51-b8c2-3ee73ede20da/nuget/v3/index.json -ApiKey VSTS -Verbosity Detailed
2018-02-01T15:55:21.7455077Z NuGet Version: 4.3.0.4406
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: "C:\agent\_work\_tasks\NuGetCommand_333b11bd-d341-40d9-afcf-b32d5ce6f23b.0.7\node_modules\nuget-task-common\NuGet\CredentialProvider\CredentialProvider.TeamBuild.exe" -uri https://{tfs_server_location}/Mobile Applications/_packaging/a4a3b7fe-b530-4e51-b8c2-3ee73ede20da/nuget/v3/index.json -nonInteractive -verbosity detailed
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: URI Prefixes:
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: https://{tfs_server_location}/Mobile Applications/
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: URI: https://{tfs_server_location}/Mobile
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: Is retry: False
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: Matched prefix:
2018-02-01T15:55:22.3854366Z CredentialProvider.TeamBuild: This provider only handles URIs from the build's Team Project Collection
2018-02-01T15:55:22.7448581Z Unable to load the service index for source https://{tfs_server_location}/Mobile%20Applications/_packaging/a4a3b7fe-b530-4e51-b8c2-3ee73ede20da/nuget/v3/index.json.
2018-02-01T15:55:22.7448581Z Response status code does not indicate success: 401 (Unauthorized).
2018-02-01T15:55:22.7610511Z NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source https://{tfs_server_location}/Mobile%20Applications/_packaging/a4a3b7fe-b530-4e51-b8c2-3ee73ede20da/nuget/v3/index.json. ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
2018-02-01T15:55:22.7610511Z at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.HttpSource.<>c__DisplayClass12_0`1.<<GetAsync>b__0>d.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLockedAsync>d__2`1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.HttpSource.<GetAsync>d__12`1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of inner exception stack trace ---
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.ServiceIndexResourceV3Provider.<TryCreate>d__8.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__16`1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.PackageUpdateResourceV3Provider.<TryCreate>d__1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__16`1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__15`1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Commands.CommandRunnerUtility.<GetPackageUpdateResource>d__3.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Commands.PushRunner.<Run>d__0.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.CommandLine.PushCommand.<ExecuteCommandAsync>d__28.MoveNext()
2018-02-01T15:55:22.7916018Z ##[error]Error: C:\agent\_work\_tool\NuGet.3.0\x64\nuget.exe failed with return code: 1
2018-02-01T15:55:22.7916018Z ##[error]Packages failed to publish
2018-02-01T15:55:22.8228295Z ##[section]Finishing: NuGet push
最初,我们试图通过在 NuGet 推送构建步骤中选择 "Target feed location" 部分下的 "This account/collection" 选项将 NuGet 包推送到 TFS 源,如您所见 here.
然而,我们甚至尝试了“外部 NuGet 服务器(包括其他 accounts/collections)”选项(上图中红色轮廓的右侧),我们将 URL 添加到 NuGet feed 和我的凭据以及我本周早些时候创建的 PAT,我们得到了同样的错误。
有趣的是,每当我在我的计算机上调用 nuget push
命令 Powershell,并使用我的用户名和 PAT 传入相同的 .nupkg
文件时,它都能够毫无问题地推送;当我尝试通过远程桌面连接到 TFS 服务器来执行相同的操作时,出现了同样的问题。
还有其他人遇到过这个问题吗?有没有人解决这个问题或可以帮助我们走上正确的道路?
关于可执行 JAR 的注意事项:在我们的构建过程中,我们调用一个 Powershell 脚本,该脚本收集额外的参数以作为命令行参数传递给可执行 JAR。然后,当构建中的一个阶段完成时,JAR 使用此信息来增加版本号的一部分,版本号遵循 major.minor.build.revision 格式。在过去的几个月里,我们一直在 Jenkins 上使用这个 JAR,它并没有影响我们将可用的 NuGet 包推送到我们的 Nexus 存储库的能力。
请尝试以下项目以缩小问题范围:
确认在您的 TFS AT 上禁用了 IIS 基本身份验证。
像 nuget.exe 那样通过基本身份验证发送的令牌在那些任务中使用,在启用 IIS 基本身份验证时将不起作用。有点混乱,但基本上 IIS 会干扰 TFS 验证基本凭据的能力。
详情请参考这篇文章:Enabling IIS Basic Authentication invalidates using Personal Access Tokens
尝试 运行 构建代理作为“普通”用户(设置您自己的使用
帐户作为构建代理服务帐户)
有关详细信息,请参阅此类似主题:
NuGet Publisher build task fails with errors 401 (Unauthorized) and 402 (Payment Required)
NuGet 推送导致 TFS 构建和 TFS 服务器本身出现 401 未经授权的错误
我们正在从 BitBucket、Jenkins 和 Nexus 过渡到 TFS 2018 以容纳我们的 Git 存储库、持续集成我们的 C# 代码并存储我们的构建工件。我们正在我们的 TFS 服务器上添加我们的第一个构建定义,并且我们的构建定义(如下)成功,直到我们进入 NuGet 推送步骤。
- 获取源代码 - 从同一 TFS 服务器克隆 Git 存储库
- NuGet 工具安装程序(版本 0.*) - 安装 NuGet 4.3.0
- 下载文件(版本 1.*) - 下载要在构建过程中使用的可执行 JAR(有关详细信息,请参见底部)。
- NuGet(版本 2.*) - 在我们的解决方案中恢复 NuGet 包
- Powershell(版本 1.*) - 调用 JAR 以在我们的
.nuspec
文件中为 NuGet 打包步骤填充依赖项。 - Powershell(版本 1.*) - 调用 JAR 以增加修订版本号(有关更多信息,请参见底部)。
- MSBuild(版本 1.*) - 构建解决方案
- Powershell(版本 1.*) - 调用 JAR 以增加内部版本号和次要版本号(有关更多信息,请参见底部)。
- NuGet(版本 1.*) - 打包 NuGet 包
- NuGet(版本 1.*) - 将 NuGet 包推送到 TFS 上的 NuGet 提要
- Powershell(版本 1.*) - 调用 JAR 将最终版本号存储在服务器上,以便在未来的构建中使用(更多信息见底部) .
当我们到达推送 NuGet 包的第 10 步时,我们收到以下错误,即使项目构建服务是 NuGet 源上的 "Owner",并且构建的项目授权范围定义设置为 "Project Collection."
2018-02-01T15:55:20.2291785Z ##[section]Starting: NuGet push
2018-02-01T15:55:20.2291785Z ==============================================================================
2018-02-01T15:55:20.2291785Z Task : NuGet
2018-02-01T15:55:20.2291785Z Description : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet.
2018-02-01T15:55:20.2291785Z Version : 2.0.7
2018-02-01T15:55:20.2291785Z Author : Microsoft Corporation
2018-02-01T15:55:20.2291785Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2018-02-01T15:55:20.2291785Z ==============================================================================
2018-02-01T15:55:20.9633816Z [command]C:\WINDOWS\system32\chcp.com 65001
2018-02-01T15:55:21.0259411Z Active code page: 65001
2018-02-01T15:55:21.0416108Z SYSTEMVSSCONNECTION exists true
2018-02-01T15:55:21.0727651Z Detected NuGet version 4.3.0.4406 / 4.3.0
2018-02-01T15:55:21.1509681Z Saving NuGet.config to a temporary config file.
2018-02-01T15:55:21.1668061Z ##[warning]No package sources were found in the NuGet.config file at C:\agent\_work\Nuget\tempNuGet_178.config
2018-02-01T15:55:21.1821145Z [command]C:\agent\_work\_tool\NuGet.3.0\x64\nuget.exe push C:\agent\_work\a\{name_of_our_nuget_package}.nupkg -NonInteractive -Source https://{tfs_server_location}/Mobile%20Applications/_packaging/a4a3b7fe-b530-4e51-b8c2-3ee73ede20da/nuget/v3/index.json -ApiKey VSTS -Verbosity Detailed
2018-02-01T15:55:21.7455077Z NuGet Version: 4.3.0.4406
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: "C:\agent\_work\_tasks\NuGetCommand_333b11bd-d341-40d9-afcf-b32d5ce6f23b.0.7\node_modules\nuget-task-common\NuGet\CredentialProvider\CredentialProvider.TeamBuild.exe" -uri https://{tfs_server_location}/Mobile Applications/_packaging/a4a3b7fe-b530-4e51-b8c2-3ee73ede20da/nuget/v3/index.json -nonInteractive -verbosity detailed
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: URI Prefixes:
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: https://{tfs_server_location}/Mobile Applications/
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: URI: https://{tfs_server_location}/Mobile
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: Is retry: False
2018-02-01T15:55:22.1513242Z CredentialProvider.TeamBuild: Matched prefix:
2018-02-01T15:55:22.3854366Z CredentialProvider.TeamBuild: This provider only handles URIs from the build's Team Project Collection
2018-02-01T15:55:22.7448581Z Unable to load the service index for source https://{tfs_server_location}/Mobile%20Applications/_packaging/a4a3b7fe-b530-4e51-b8c2-3ee73ede20da/nuget/v3/index.json.
2018-02-01T15:55:22.7448581Z Response status code does not indicate success: 401 (Unauthorized).
2018-02-01T15:55:22.7610511Z NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source https://{tfs_server_location}/Mobile%20Applications/_packaging/a4a3b7fe-b530-4e51-b8c2-3ee73ede20da/nuget/v3/index.json. ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
2018-02-01T15:55:22.7610511Z at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.HttpSource.<>c__DisplayClass12_0`1.<<GetAsync>b__0>d.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Common.ConcurrencyUtilities.<ExecuteWithFileLockedAsync>d__2`1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.HttpSource.<GetAsync>d__12`1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of inner exception stack trace ---
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.ServiceIndexResourceV3Provider.<TryCreate>d__8.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__16`1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.PackageUpdateResourceV3Provider.<TryCreate>d__1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__16`1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__15`1.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Commands.CommandRunnerUtility.<GetPackageUpdateResource>d__3.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.Commands.PushRunner.<Run>d__0.MoveNext()
2018-02-01T15:55:22.7610511Z --- End of stack trace from previous location where exception was thrown ---
2018-02-01T15:55:22.7610511Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-02-01T15:55:22.7610511Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-02-01T15:55:22.7610511Z at NuGet.CommandLine.PushCommand.<ExecuteCommandAsync>d__28.MoveNext()
2018-02-01T15:55:22.7916018Z ##[error]Error: C:\agent\_work\_tool\NuGet.3.0\x64\nuget.exe failed with return code: 1
2018-02-01T15:55:22.7916018Z ##[error]Packages failed to publish
2018-02-01T15:55:22.8228295Z ##[section]Finishing: NuGet push
最初,我们试图通过在 NuGet 推送构建步骤中选择 "Target feed location" 部分下的 "This account/collection" 选项将 NuGet 包推送到 TFS 源,如您所见 here.
然而,我们甚至尝试了“外部 NuGet 服务器(包括其他 accounts/collections)”选项(上图中红色轮廓的右侧),我们将 URL 添加到 NuGet feed 和我的凭据以及我本周早些时候创建的 PAT,我们得到了同样的错误。
有趣的是,每当我在我的计算机上调用 nuget push
命令 Powershell,并使用我的用户名和 PAT 传入相同的 .nupkg
文件时,它都能够毫无问题地推送;当我尝试通过远程桌面连接到 TFS 服务器来执行相同的操作时,出现了同样的问题。
还有其他人遇到过这个问题吗?有没有人解决这个问题或可以帮助我们走上正确的道路?
关于可执行 JAR 的注意事项:在我们的构建过程中,我们调用一个 Powershell 脚本,该脚本收集额外的参数以作为命令行参数传递给可执行 JAR。然后,当构建中的一个阶段完成时,JAR 使用此信息来增加版本号的一部分,版本号遵循 major.minor.build.revision 格式。在过去的几个月里,我们一直在 Jenkins 上使用这个 JAR,它并没有影响我们将可用的 NuGet 包推送到我们的 Nexus 存储库的能力。
请尝试以下项目以缩小问题范围:
确认在您的 TFS AT 上禁用了 IIS 基本身份验证。
像 nuget.exe 那样通过基本身份验证发送的令牌在那些任务中使用,在启用 IIS 基本身份验证时将不起作用。有点混乱,但基本上 IIS 会干扰 TFS 验证基本凭据的能力。
详情请参考这篇文章:Enabling IIS Basic Authentication invalidates using Personal Access Tokens
尝试 运行 构建代理作为“普通”用户(设置您自己的使用 帐户作为构建代理服务帐户)
有关详细信息,请参阅此类似主题: NuGet Publisher build task fails with errors 401 (Unauthorized) and 402 (Payment Required)