nugetmyget

How to get the myget package source?


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?


Solution

  • 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?