Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

provide credentials in nuget command line parameters

Tags:

nuget

We have an nuget server hosted in azure that only allow certain people to create packages.

If I run nuget command line, I get asked to provide username and password. Is there a possibility to provide username and password in command line?

I tried something such as -User or -UserName, but I get Unknown option: '-User'

nuget push -Source "XXX" -ApiKey VSTS -noninteractive mypackage.*.nupkg -User myUsername 

Is there a way to provide credentials from command line?

like image 504
daxu Avatar asked Feb 01 '17 12:02

daxu


People also ask

How do I update NuGet credentials?

Steps: Go to Control Panel -->User Account -->Credential Manager. In window credentials section update the password of your artifactory with encrypted password.

Where are NuGet credentials stored?

Globally: to make a credential provider available to all instances of nuget.exe run under the current user's profile, add it to %LocalAppData%\NuGet\CredentialProviders .


2 Answers

You have to change the NuGet.config you use. That is possible from the command line:

nuget sources add -Name "MyExample" -Source "XXX" -username "Y" -password "Z" 

The password will be stored encrypted in the config file and can only be decrypted in the same user context as it was encrypted.

like image 117
Jeroen Heier Avatar answered Sep 20 '22 23:09

Jeroen Heier


Use PAT (Personal Access Token) as the password. Make sure that PAT has packaging read and write permission.

like image 43
Jie Zhao Avatar answered Sep 21 '22 23:09

Jie Zhao