Cannot restore internal NuGet packages

When working with projects that has dependencies on an internal NuGet registry, you may need add credentials for the internal registry so that NuGet can fetch the packages.

If you restore in Visual Studio, it’s possible that VS will ask you to provide credentials (not yet tested).

If you try to restore or build using the command line, it may fail with unauthorized error.

To resolve, modify nuget.config file, either in the same folder of the solution file, or modify the global nuget.config file.

<packageSourceCredentials>
<MyPrivateNugetRegistry>
<add key=”Username” value=”Your username here” />
<add key=”ClearTextPassword” value=”your password/access token here” />
</MyPrivateNugetRegistry>
</packageSourceCredentials>