Skip to content

Instantly share code, notes, and snippets.

@xavierdecoster
Last active July 12, 2022 12:43
Show Gist options
  • Save xavierdecoster/3205826 to your computer and use it in GitHub Desktop.
Save xavierdecoster/3205826 to your computer and use it in GitHub Desktop.
Store MyGet credentials in your roaming user profile NuGet.config

Execute the following script using your MyGet [feedUrl] and MyGet [username] , [password] and [apikey]. Run this from a commandline where you have access to nuget.exe (or set the path to your nuget.exe in a system environment variable).

Store credentials in machine-level nuget.config (non-transferable)

nuget setapikey [apikey] -source [feedUrl]
nuget sources add|update -Name [name] -source [feedUrl] -User [username] -pass [password]

Store credentials in specific nuget.config (non-transferable)

nuget setapikey [apikey] -source [feedUrl] -configFile [configFilePath]
nuget sources add|update -Name [name] -source [feedUrl] -User [username] -pass [password] -configFile [configFilePath]

Store credentials in specific nuget.config (transferable)

Don't bother putting the above nuget.config files into source control as they'll only work on the machine and the account that created the configs.

To be able to share credentials, use the -StorePasswordInClearText option:

nuget setapikey [apikey] -source [feedUrl] -configFile [configFilePath]
nuget sources add|update -Name [name] -source [feedUrl] -User [username] -pass [password] -configFile [configFilePath] -StorePasswordInClearText
@michaelaird
Copy link

I'm trying this solution to work around the bug in TeamCity/Nuget around the authenticated feed but it still doesn't seem to be working. What is the right directory to put the nuget.config file in? Is it case sensitive (NuGet.config vs nuget.config)? does the source URL need to match the "internal"/localhost url of the feed? trailing / or no trailing /?

so many questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment