title: Azure build pipeline unable to restore NuGet packages from private feed when using NuGet.Config file from solution
body: <p>I am trying to build a C# project in DevOps build pipeline. The project is using a single Azure Artifacts private feed. The NuGet.config is as given by the Azure portal from the Nuget tab of connect feed page. The file is at the root of the solution.</p>
  <p><strong>NuGet.config</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;configuration&gt;
    &lt;config&gt;
      &lt;add key=&quot;repositorypath&quot; value=&quot;.\packages&quot; /&gt;
      &lt;packageSources&gt;
        &lt;clear /&gt;
        &lt;add key=&quot;&lt;myfeedname&gt;&quot; value=&quot;https://pkgs.dev.azure.com/&lt;myorg&gt;/&lt;myproject&gt;/_packaging/&lt;myfeedname&gt;/nuget/v3/index.json&quot; /&gt;
      &lt;/packageSources&gt;
    &lt;/config&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>I am having difficulty restoring packages when using NuGet.config from the solution. The log shows some evidence of using the azure org related URLs but not the project or feed. The restore cannot find packages. However, if I specify the feed and package folder in the NuGet restore task itself, it works fine and downloads all packages. I am expecting the task to find the private feed URL automatically from the NuGet.config file, authenticate (since inside pipeline), and download packages. The config file works fine in local builds asking for org user credentials (pop up) when using VS. The NuGet.config is checked into repo and hence there are no credentials used.</p>
  <p>I also have NuGet Authenticate task just in case. (The working version doesn't even need this task).</p>
  <pre><code>- task: NuGetAuthenticate@0
  </code></pre>
  <p>What is wrong with the non-working version?</p>
  <p><strong>Working Version:</strong></p>
  <pre><code>- task: NuGetCommand@2
    displayName: &quot;Step: Restore NuGet&quot;
    inputs:
      command: 'restore'
      feedsToUse: 'select'
      vstsFeed: '&lt;myproject&gt;/&lt;MyFeed&gt;'
      includeNuGetOrg: false
      restoreSolution: '$(solution)'
      restoreDirectory: &quot;../../packages&quot;
      verbosityRestore: Detailed
    continueOnError: true
  </code></pre>
  <p><strong>Non-Working Version:</strong></p>
  <pre><code>- task: NuGetCommand@2
    displayName: &quot;Step: Restore NuGet&quot;
    inputs:
      command: 'restore'
      restoreSolution: '$(solution)'
      feedsToUse: 'config'
      nugetConfigPath: &quot;NuGet.config&quot;
      verbosityRestore: Detailed
    continueOnError: true
  </code></pre>
  <p>From non-working version, the log shows that it is using the file as expected.</p>
  <pre><code>C:\hostedtoolcache\windows\NuGet\5.8.1\x64\nuget.exe restore D:\a\1\s\&lt;solution-file-path&gt; -Verbosity Detailed -NonInteractive -ConfigFile D:\a\1\s\NuGet.config
  </code></pre>
  <p>NuGet Version: 5.8.1.7021</p>
  <p><strong>Some errors:</strong></p>
  <pre><code>WARNING: Unable to find version '6.0.0' of package 'Microsoft.CodeAnalysis.NetAnalyzers'.
  NU1100: Unable to resolve 'AsyncFixer (&gt;= 1.5.1)' for '.NETFramework,Version=v4.8'.
  </code></pre>
  <p>I also find some logs related to devops org for auth but no mention of project or feed name,</p>
  <pre><code>##[debug]Discovered URL prefixes: https://dev.azure.com/&lt;my-org&gt;/,.....others....
  :
  ##[debug]Got auth token
  ..
  :
  ##[error]Packages failed to restore
  </code></pre>
  <p>No mention of NuGet sources used in log. (System.Debug set to true in variables)</p>
  <p>The working version shows the private feed as source used at the end.</p>
  <pre><code>NuGet Config files used:
      D:\a\1\Nuget\tempNuGet_2852.config
  
  Feeds used:
      https://pkgs.dev.azure.com/&lt;org&gt;/&lt;proj&gt;/_packaging/&lt;feed&gt;/nuget/v3/index.json
  </code></pre>
  <p>However, I want to use the config version since it seems to be the right approach.</p>