Search code examples
nuget

provide credentials in nuget command line parameters


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?


Solution

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