dotnet restore fails in the pipeline with NU1101 or 401 Unauthorized. How do you fix it?

IntermediateTroubleshooting.NET builds (dotnet CLI)
Answer

Short answer

NU1101 "Unable to find package" means none of the configured feeds has that package (wrong feed, typo, or the private feed isn't configured on the agent). 401 Unauthorized means the feed was found but the pipeline isn't authenticated to it. Fix the nuget.config sources and give the pipeline credentials for the private feed.

Steps

  1. Look at which feed and package failed in the log.
  2. Check nuget.config in the repo lists the private feed:
    <packageSources>
      <clear />
      <add key="company" value="https://pkgs.dev.azure.com/org/_packaging/shop/nuget/v3/index.json" />
      <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    </packageSources>
    
  3. Authenticate:
    • Azure DevOps: - task: NuGetAuthenticate@1 before restore, and grant the build service access to the feed.
    • GitHub Actions / others: dotnet nuget add source ... --username x --password ${{ secrets.FEED_PAT }} --store-password-in-clear-text.
  4. For NU1101, confirm the package name and version exist in the feed (internal packages may not be published yet).
  5. Behind a corporate proxy? Set HTTPS_PROXY for the agent.

What to say in the interview

"NU1101 is a missing package across the configured sources; 401 is an authentication issue. I verify nuget.config sources, then authenticate the pipeline with NuGetAuthenticate in Azure DevOps or a PAT secret elsewhere, and make sure the build identity has feed permissions."

All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: .NET apps: dotnet build & publish

More on .NET builds (dotnet CLI)