Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet and VS2013 ignoring packageSourceCredentials in nuget.config

I have a private nuget server which I am trying to pull packages from (eventually Azure build agent but I am trying this locally first).

I am using the 2.7 NuGet meaning I do not need .NuGet folder (along with .exe and .targets). I have a nuget.config in my solution directory.

I know the nuget.config is being picked up, as it locates my remote repository but the credentials supplied in the config are not used.

Here is my config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <packageSources>
    <add key="https://www.nuget.org/api/v2/" value="https://www.nuget.org/api/v2/" />
    <add key="myrepo" value="http://myrepo:81/nuget/myfeed" />
  </packageSources>
  <disabledPackageSources />
  <packageSourceCredentials>
    <myrepo>
      <add key="Username" value="user" />
      <add key="ClearTextPassword" value="pass" />
    </myrepo>
  </packageSourceCredentials>
</configuration>

What would cause nuget to ignore these credentials? I have checked with Fiddler and no credentials are being sent, and the server responds with a 401 (correctly):

Error   1   NuGet Package restore failed for project MyProject: The remote server returned an error: (401) Unauthorized..       0   0   
like image 954
James Avatar asked Jun 09 '14 16:06

James


1 Answers

Use the 'Manage NuGet Packages' dialog ! Do not rely on building/rebuilding in Visual Studio expecting that it will restore the missing packages. Open the 'Manage NuGet Packages' for a project (right click on a failing project and choose the option) and you will see a message "Some packages are missing for this project..." with a 'Restore' button. Restoring using that button will resolve these authentication issues.

like image 109
dwicks Avatar answered Oct 19 '22 19:10

dwicks