2
votes

I am using myget for my Nuget packages. Because i am using a private feed with credentials, i followed this blog: http://www.xavierdecoster.com/deploying-to-azure-web-sites-using-nuget-package-restore-from-a-secured-feed

My local (project) nuget.config (located in the .nuget folder in the solution) looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
  <packageSource>
    <clear />

    <add key="EcareMyGet" value="https://www.myget.org/F/rai69/"></add>

  </packageSource>
  <activePackageSource>
    <add key="EcareMyGet" value="https://www.myget.org/F/rai69/"></add>
  </activePackageSource>
  <packageSourceCredentials>
    <EcareMyGet>
      <add key="Username" value="www.myget.org/raimond" />
      <add key="ClearTextPassword" value="wachtwoord" />
    </EcareMyGet>
  </packageSourceCredentials>
</configuration> 

In my nuget.targets i've changed the restore command according to the blog:

<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)"   -NonInteractive   $(RequireConsentSwitch) -solutionDir "$(SolutionDir)\" -Verbosity detailed </RestoreCommand>

Despite this, the buildserver is still using nuget.org as source:

NuGet.exe sources
  Registered Sources:

    1.  https://nuget.org/api/v2/ [Enabled]
        https://nuget.org/api/v2/

Who knows a solution?

2

2 Answers

2
votes

Answer: replace <packageSource> by <packageSources> in the nuget.config file

Below is the conversation that lead to the answer...

Just to be sure, did you also read the part where you disable the -RequireConsent switch?

<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">
false
</RequireRestoreConsent>

Also, make sure you didn't configure it in the MSBuild PackageSources element, which by default looks as shown below (no package source configured):

<ItemGroup Condition=" '$(PackageSources)' == '' ">
    <!-- Package sources used to restore packages. 
         By default, registered sources under %APPDATA%\NuGet\NuGet.Config 
         will be used -->
    <!-- The official NuGet package source (https://nuget.org/api/v2/) will be 
         excluded if package sources are specified and it does not appear 
         in the list -->
    <!--
        <PackageSource Include="https://nuget.org/api/v2/" />
        <PackageSource Include="https://my-nuget-source/nuget/" />
    -->
</ItemGroup>

If you did and that's not the issue, can you please share a little more detail about the output logs so I can determine when the issue is caused and by what command?

0
votes

You write that you use "My local (project) nuget.config", which makes me believe that you have the nuget.config file located in your project folder.

You can read about the NuGet Config File here. There you'll see that "NuGet first loads NuGet.config from the default location, then loads any file named NuGet.config starting from the root of the current drive and ending in the current directory.".

What this means, it that NuGet will look for the configuration in the folder hierarchy all the way from the root and to the location of nuget.exe, which usually is under the .nuget folder in the solution root. This means that it will never look inside the project folders in your solution. So you can try to move your nuget.config to the solution folder, and see it it gets read properly then.