Credentials problem publishing to Visual Studio Online's NuGet feed

We created an external NuGet feed in our Visual Studio Online instance.   (It's a new feature of VSO, see https://www.visualstudio.com/get-started/package/use/publish)

We're using TC to publish a package to this feed.  The feed is protected within a combination of API Key and Username/Password credentials.   However, when running the build, we get the following error in the NuGet Publish step:

Starting NuGet.exe 3.3.0.212 from E:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe
[15:12:46]Please provide credentials for: https://<<mysite>>.pkgs.visualstudio.com/DefaultCollection/_packaging/<<rest of URL hidden for security>>
[15:12:46]Cannot prompt for input in non-interactive mode.
[15:12:46]UserName:
[15:12:46]Process exited with code 1


 


We ensured the following was setup:





1.  NuGet Publish step has the correct NuGet endpoint URL and API key
2.  Enabled the NuGet Feed Credentials build feature with the same NuGet endpoint URL as above with correct credentials
2.  Basic HTTP is enabled






Why is the NuGet server still asking for a Username or set of credentials?   Is TC's NuGet Feed Credentials feature not supported when using NuGet 3.x?





9 comments

Forgot to add, we're using TeamCity Enterprise 9.1.4 (build 37293)

0

Hello,

There is a bug in TeamCity NuGet 3.3.x integration if Username/Password credentials are used. We are working on the issue and going to provide fix ASAP.
Sorry for the inconvenience.

0

Hello, ASAIK Visual Studio Team Services requires you to use personal access token to publish your packages. Basic HTTP authentication is not intended to work from nuget.exe itself and as a result from TeamCity.
Also please make sure you have all the permissions to publish packages. Basically you should be able to publish packages from nuget.exe. If if works it should work from TeamCity.

0

The "Personal Access Token" approach requires manually adding the VSTS feed source through a nuget command line call.   Theoretically, it would store the token in the global NuGet config, then we should be able to use an API Key going forward.  We tried this with the default NuGet instance in TC manually, as well as a separate build step.   It still kept asking for the username per the original message, which is why we tried VSTS Alternative Credentials, which also failed.

Again, we can access the NuGet feed outside of TC... but not from the TC build step.

0

Following the steps in VSTS for PAS generation, we had VSTS generate the NuGet Credentials, then added the feed source to TeamCity build agent's global nuget config through command line:
nuget sources add -name "MySpecialFeed" -source https://mysite.pkgs.visualstudio.com/DefaultCollection/_packaging/MySpecialFeed/nuget/v3/index.json -username "tldav" -password "zb6gsa5yyfhjx53qiqdfcfbogpvqvdth5vqqbqbiex7pvn54qsgb"

Turns out that the -password value that VSTS generates is the API Key value.    I successfully executed a push from the NuGet command line directly.   However, using the same API Key and feed URL in the NuGet Publish step in TC, I still keep getting the Username prompt error.   What are we missing here?

 

0

Hello,

There were changes in authentication methods in NuGet 3.3.x and currently TeamCity does not support publishing using NuGet Feed Credentials build feature. We reopened the issue https://youtrack.jetbrains.com/issue/TW-43449, please watch it to get the status updates.
As workaround you can use NuGet 2.x version.

0

Thanks.  It seems the workaround with NuGet 2.8 appears to run.   In case others use VSTS new NuGet repo, here are the steps we performed:

In VSTS:
1.  Setup Alternative Credentials for your logged-in account within VSTS
2.  Within VSTS, select your NuGet Feed, then click "Connect to Feed" to open the feed connection modal
3.  In the modal, choose "NuGet 2x" as the tool.  It'll give you the appropriate NuGet URL endpoint.
4.  In the same modal, create a Personal Access Token by clicking the "Generate NuGet Credentials" button.  The result is a NuGet command line with arguments, and the "password" argument contains your API Key.

Then, in TC:
5.  In your build config,  add a "NuGet Feed Credentials" Build Feature and enter the NuGet URL endpoint and your VSTS Alternate Credentials username/password (NOT the API Key).
6.  Go to your NuGet Publish step and use the same NuGet URL endpoint and enter the API Key from Step 4 above.

So, in short, it seems you need BOTH the VSTS API Key and the VSTS Alternate Credentials with Basic HTTP to make this work in 2.x.   Will this be the case in 3.x as well?

0

Thank you for sharing the steps!
Yes, you'll need API key and username/password in 3.x as well. At the moment Visual Studio Online supports NuGet publishing using both of them.

0

Please sign in to leave a comment.