Reputation: 3
We are in the process of transitioning from BitBucket, Jenkins, and Nexus to TFS 2018 to house our Git repository, continuously integrate our C# code, and store our build artifacts. We are in the process of adding our first build definition on our TFS server, and our build definition (below) succeeds until we get to the NuGet Push step.
.nuspec
file for the NuGet pack step.When we get to Step 10, which pushes the NuGet package, we get the following error, even though the Project Build Service is an "Owner" on the NuGet feed, and the Project Authorization scope of the build definition is set to "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\5\Nuget\tempNuGet_178.config
2018-02-01T15:55:21.1821145Z [command]C:\agent\_work\_tool\NuGet\4.3.0\x64\nuget.exe push C:\agent\_work\5\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\2.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\4.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
Originally, we were trying to push the NuGet package to the TFS feed by selecting the "This account/collection" option under the "Target feed location" section in the NuGet push build step as you can see here.
However, we even tried the “External NuGet server (including other accounts/collections)” option (the right of the red outline in the image above) where we added the URL to the NuGet feed and my credentials with my PAT that I created earlier this week, and we got the same error.
Interestingly enough, whenever I invoke the nuget push
command Powershell on my computer, and pass in the same .nupkg
file with my username and PAT, it is able to push without issue; when I try to do the same from the TFS server by connecting to it via Remote Desktop, the same issue occurs.
Has anyone else been experiencing this issue? Does anyone have a fix for this issue or could help us down the right path?
Note regarding executable JAR: In our build process, we invoke a Powershell script that gathers additional arguments to pass to an executable JAR as command line arguments. Then, the JAR uses this information to increment parts of our version number, which follows the major.minor.build.revision format, when a stage in our build completes. We have been using this JAR for the past couple of months on Jenkins, and it has not affected our ability to push usable NuGet packages to our Nexus Repository.
Upvotes: 0
Views: 2928
Reputation: 30422
Please try below items to narrow down the issue:
Confirm that IIS Basic Authentication is disabled on your TFS AT.
Tokens sent via Basic authentication like nuget.exe does in those tasks use will not work when IIS Basic Authentication is enabled. Slightly confusing, but basically IIS interferes with TFS's ability to authenticate Basic credentials.
Refer to this article for details : Enabling IIS Basic Authentication invalidates using Personal Access Tokens
Try running the build agent as a "normal" user (set your own use account as the build agent service account)
Refer to this similar thread for details: NuGet Publisher build task fails with errors 401 (Unauthorized) and 402 (Payment Required)
Upvotes: 1