Authenticating to VSTS Package Management

2019-05-19 08:06发布

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).

1条回答
Evening l夕情丶
2楼-- · 2019-05-19 08:40

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.

查看更多
登录 后发表回答