2

The documentation shows connecting to a VSTS Package Management feed via either a CredentialProvider (which prompts for a username/password), or for a v2 feed saving the username/PAT in the nuget.config itself.

I'd like to be able to pass in the credentials at build time on a build server (not VSTS Build). Is there a way to do this without having to manually log in to the build server and configure the CredentialProvider, or by committing the credentials in the nuget.config file to source control?

This would be both for consuming packages and also for publishing new packages (that are artifacts from the build).

David Gardiner
  • 16,892
  • 20
  • 80
  • 117
  • I've found a few references to "VstsNuGetPush.exe" which might help with this, but not sure if that's something that can be downloaded or is only internal to VSTS/TFS. – David Gardiner Jan 29 '18 at 23:48
  • What do you mean "I'd like to be able to pass in the credentials at build time on a build server (not VSTS Build)"? Doesn't you want to add credentials during VSTS build process? – Marina Liu Jan 30 '18 at 05:18
  • To clarify, I'm not using VSTS Builds. "Passing in credentials" means some way of passing in username/password/PAT as parameters at build/runtime to what ever tool I need to use to push the packages to the feed. – David Gardiner Jan 30 '18 at 23:33

1 Answers1

3

Actually you can add the credential to the build server for once, then you can connect to VSTS package feed automatically.

For the first time to build on the build server, execute below commands to add credentials and apikey:

nuget.exe sources Add -Name "feedname" -Source "https://account.pkgs.visualstudio.com/_packaging/feed/nuget/v3/index.json" -username name -password password
nuget.exe setapikey vstskey –source feedname

Note: for the added credential, you can use PAT or Alternate credentials.

Then you can connect with the VSTS feed by inputting the source name only. Such as if you want to push a nuget package to the VSTS feed, just use the command:

nuget.exe push –source feedname –apikey vstskey path/to/name.nupkg

Or you can add the nuget.config file (which credentials) into source control, and when use nuget cli, just specify the path of the nuget.config file you used.

David Gardiner
  • 16,892
  • 20
  • 80
  • 117
Marina Liu
  • 36,876
  • 5
  • 61
  • 74