Chris Straw

Eliminate multiple Nuget sources password prompt

When you have multiple Nuget sources and when you open a Visual Studio project, you might get prompted for which account to login to Nuget for package restore.

I find this annoying, so I configure Nuget to store the hashed token in the global Nuget.config.

This command adds the package source credential elements to the nuget.config file:

  • nuget.exe sources update -Name “{package-feed-1}” -UserName “{email-address-1}” -Password “{devops-token-1}”
  • nuget.exe sources update -Name “{package-feed-2}” -UserName “{email-address-2}” -Password “{devops-token-2}”


<?xml version="1.0" encoding="utf-8"?>
    <add key="" value="" protocolVersion="3" />
    <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
    <add key="{package-source-1}" value="https://{devops-url-1}/_packaging/{package-source-1}/nuget/v3/index.json" />
    <add key="{package-source-2}" value="https://{devops-url-2}/_packaging/{package-source-2}/nuget/v3/index.json" />
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
    <add key="skip" value="False" />
    <add key="format" value="0" />
    <add key="disabled" value="False" />
        <add key="Username" value="{email-address-1}" />
        <add key="Password" value="{hashed-devops-token-1}" />
      <add key="Username" value="{email-address-2}" />
      <add key="Password" value="{hashed-devops-token-2}" />