Octopack - NuGet push credentials TFS package feed

Hi Guys,

I’m having issues with pushing my packages to our internal NuGet feed that I created using TFS2017 packages tab.

Also created a Stackoverflow post: http://stackoverflow.com/questions/43227208/tfs2017-nuget-push-with-octopack-credentials

I’m getting the following error:

2017-04-05T09:08:24.8336348Z 6>OctoPack:
2017-04-05T09:08:24.8336348Z Please provide credentials for: http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json
2017-04-05T09:08:24.9273850Z Unable to load the service index for source http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json.
2017-04-05T09:08:24.9273850Z Response status code does not indicate success: 401 (Unauthorized).
2017-04-05T09:08:24.9273850Z UserName: Password:
2017-04-05T09:08:24.9430236Z ##[error]Source\packages\OctoPack.3.4.2\tools\OctoPack.targets(108,5): Error MSB3073: The command "“C:\TFS_Agents\Product_Agent_1_work\2\s\Source\packages\OctoPack.3.4.2\tools\NuGet.exe” push “C:\TFS_Agents\Product_Agent_1_work\2\s\Source\Company.Product.ServiceBus\obj\octopacked\Company.Product.ServiceBus.Release.3.5.0.nupkg” -Source http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json " exited with code 1.
2017-04-05T09:08:24.9430236Z 6>C:\TFS_Agents\Product_Agent_1_work\2\s\Source\packages\OctoPack.3.4.2\tools\OctoPack.targets(108,5): error MSB3073: The command "“C:\TFS_Agents\Product_Agent_1_work\2\s\Source\packages\OctoPack.3.4.2\tools\NuGet.exe” push “C:\TFS_Agents\Product_Agent_1_work\2\s\Source\Company.Product.ServiceBus\obj\octopacked\Company.Product.ServiceBus.Release.3.5.0.nupkg” -Source http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json " exited with code 1. [C:\TFS_Agents\Product_Agent_1_work\2\s\Source\Company.Product.ServiceBus\Company.Product.ServiceBus.csproj]
I want to push packages to it with OctoPack using the following build parameters:

/p:RunOctoPack=true
/p:OctoPackPublishPackageToHttp=http://servername:8080/tfs/TCol/_packaging/Product/nuget/v3/index.json
/p:OctoPackAppendToPackageId=Release
/p:OctoPackNuGetProperties=Configuration=Release
I tried using the following:

/p:OctoPackPublishApiKey=VSTS
/p:OctoPackNuGetPushProperties=-ApiKey=VSTS
Neither parameters worked…

I also don’t mind removing the apikey / credentials from the feed but there is literally NO documentation how to do this in the new Package feature in TFS 2017.

Here’s a stacktrace I just printed out using -Verbosity detailed in the nuget push parameters:

OctoPack: OctoPack successful
Publish to repository: http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json
"C:*_Agents\Product_Agent_1_work\7\s\Source\packages\OctoPack.3.4.2\tools\NuGet.exe" push "C:*_Agents\Product_Agent_1_work\7\s\Source\Company.Product.ApiProxy.v2\obj\octopacked\Company.Product.ApiProxy.v2.Release.3.5.0.nupkg" -Source http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json -Verbosity detailed -ApiKey key
NuGet Version: 3.5.0.10252 (Custom build for OctoPack)
Please provide credentials for: http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json
System.AggregateException: One or more errors occurred. —> NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json. —> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at NuGet.Protocol.HttpSource.<>c__DisplayClass12_0.<b__0>d.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Common.ConcurrencyUtilities.d__21.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Protocol.HttpSource.<GetAsync>d__12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext() --- End of inner exception stack trace --- at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Protocol.ServiceIndexResourceV3Provider.<TryCreate>d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__161.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Protocol.PackageUpdateResourceV3Provider.d__1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Protocol.Core.Types.SourceRepository.d__161.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__151.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Commands.CommandRunnerUtility.d__3.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Commands.PushRunner.d__0.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.PushCommand.d__28.MoveNext()
— End of inner exception stack trace —
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at NuGet.CommandLine.Command.Execute()
at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
—> (Inner Exception #0) NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json. —> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at NuGet.Protocol.HttpSource.<>c__DisplayClass12_0.<b__0>d.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Common.ConcurrencyUtilities.d__21.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Protocol.HttpSource.<GetAsync>d__12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext() --- End of inner exception stack trace --- at NuGet.Protocol.ServiceIndexResourceV3Provider.<GetServiceIndexResourceV3>d__9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Protocol.ServiceIndexResourceV3Provider.<TryCreate>d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__161.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Protocol.PackageUpdateResourceV3Provider.d__1.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Protocol.Core.Types.SourceRepository.d__161.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.Protocol.Core.Types.SourceRepository.<GetResourceAsync>d__151.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Commands.CommandRunnerUtility.d__3.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Commands.PushRunner.d__0.MoveNext()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.PushCommand.d__28.MoveNext()<—

UserName: Password:
Source\packages\OctoPack.3.4.2\tools\OctoPack.targets(108,5): Error MSB3073: The command ““C:*_Agents\Product_Agent_1_work\7\s\Source\packages\OctoPack.3.4.2\tools\NuGet.exe" push "C:*_Agents\Product_Agent_1_work\7\s\Source\Company.Product.ApiProxy.v2\obj\octopacked\Company.Product.ApiProxy.v2.Release.3.5.0.nupkg” -Source http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json -Verbosity detailed -ApiKey key” exited with code 1.
C:*_Agents\Product_Agent_1_work\7\s\Source\packages\OctoPack.3.4.2\tools\OctoPack.targets(108,5): error MSB3073: The command ""C:*_Agents\Product_Agent_1_work\7\s\Source\packages\OctoPack.3.4.2\tools\NuGet.exe" push "C:*_Agents\Product_Agent_1_work\7\s\Source\Company.Product.ApiProxy.v2\obj\octopacked\Company.Product.ApiProxy.v2.Release.3.5.0.nupkg" -Source http://tfsserver:8080/tfs/COLL/_packaging/Product/nuget/v3/index.json -Verbosity detailed -ApiKey key" exited with code 1. [C:*_Agents\Product_Agent_1_work\7\s\Source\Company.Product.ApiProxy.v2\Company.Product.ApiProxy.v2.csproj]
Done Building Project “C:*_Agents\Product_Agent_1_work\7\s\Source\Company.Product.ApiProxy.v2\Company.Product.ApiProxy.v2.csproj" (default targets) – FAILED.
Project "C:*
_Agents\Product_Agent_1_work\7\s\Source\Company.Product.Solution.sln” (1) is building “C:********_Agents\Product_Agent_1_work\7\s\Source\Company.Product.ApiProxy.v2.TestConsole\Company.Product.ApiProxy.v2.TestConsole.csproj” (24) on node 1 (default targets).

Hi Tim,

Thanks for getting in touch!

Publishing to the VSTS v3 package doesn’t seem to be an option from OctoPack.

There are some instructions for publishing with nuget.exe here, but you’re right - they don’t give much information. Microsoft uses a VSTS Credential Provider, which relies on pre-configuring the credentials for nuget on the machine running nuget.exe. This has to be done before OctoPack runs, and I haven’t been able to get it to work.

One alternative is to use the v2 feed and a PAT for authentication, and there’s documentation around this as well. I think you should be able to provide the URL with the PAT, but the documentation does suggest adding the feed as a source, which may be problematic.

Finally, if you’re using the VSTS Build, there’s a NuGet Publisher step that can authenticate with the internal feed. You could use OctoPack to package the build, then this step to publish it to the internal feed. This would be my recommended solution!

I hope that helps,
Damian

Hi Damien,

Thanks for your reply!

I’m currently using the msbuild parameters /p:OctoPackPublishPackageToFileShare to package the build on the share and then use the regular NuGet Publisher step to publish all the packages inside the share to the internal feed. This seems to be working fine.

Is publishing packages from OctoPack to VSTS feed on the roadmap? Or are you depending on changes inside the Package Management in Team Services?

Thanks in advance,

Tim

Hi Tim,

To be honest, it’s probably not on the roadmap. In general, we’re trying to avoid adding too much to OctoPack, and adding support for the VSTS-specific credential manager would be a lot of work. Considering there’s a reasonable workaround (nice work on that by the way!), it’s not something I think we’d put a lot of effort towards.

Your solution seems like a great one :slight_smile:

Thanks,
Damian