Skip to content

.NET NuGet Package Restore Error Fix

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about .net nuget package restore error fix. We cover key concepts, practical examples, and best practices.

The Problem

Your .NET project fails to restore packages:

NU1101: Unable to find package Newtonsoft.Json. No packages exist with this id in source(s): nuget.org

NuGet restore errors happen when packages cannot be downloaded, source feeds are unreachable, or version constraints conflict.

Quick Fix

Step 1: Clear NuGet cache

WRONG -- assuming cache is always correct:

dotnet restore

RIGHT -- clear cache then restore:

dotnet nuget locals all --clear
dotnet restore

Step 2: Check NuGet sources

WRONG -- using default sources without verification:

dotnet nuget list source

RIGHT -- ensure nuget.org is enabled:

dotnet nuget enable source nuget.org
dotnet restore

Step 3: Fix version conflicts in project files

WRONG -- conflicting package versions across projects:

<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SomeOtherPkg" Version="2.0.0" />

RIGHT -- use CentralPackageManagement or align versions:

<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SomeOtherPkg" Version="3.0.0" />

Step 4: Handle private feed authentication

WRONG -- no credentials for private feeds:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="PrivateFeed" value="https://pkgs.dev.azure.com/..." />
  </packageSources>
</configuration>

RIGHT -- add credentials via environment variable:

dotnet nuget add source https://pkgs.dev.azure.com/... --name PrivateFeed --username PAT --password $AZURE_DEVOPS_PAT --store-password-in-clear-text

Step 5: Use lock files for deterministic restore

WRONG -- no lock file, builds differ across machines:

<PropertyGroup>
  <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

RIGHT -- check in packages.lock.json to version control:

dotnet restore --locked-mode

Prevention

  • Add a nuget.config to your repository with all required sources.
  • Use Directory.Packages.props for centralized version management.
  • Run dotnet restore with --locked-mode in CI to detect version drift.
  • Set up a local NuGet cache server for frequently used packages.
  • Use dotnet nuget locals all --clear in your CI pipeline to avoid stale caches.

Common Mistakes with nuget error

  1. Misunderstanding that String is [Char] with poor performance for large text operations
  2. Using foldl instead of foldl' causing stack overflow on large lists
  3. Forgetting deriving (Show, Eq) on custom data types needed for debugging

These mistakes appear frequently in real-world DOTNET code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### How do I fix NU1107 version conflict?

NU1107 means two packages require different versions of the same dependency. Use the dotnet nuget why command to trace why each version is needed, then add a direct PackageReference to force the version you want.

Why does restore work locally but fail in CI?

CI environments often have different NuGet sources or missing credentials. Check that your nuget.config is checked into source control and that CI secrets (feed tokens, PATs) are configured as environment variables.

What does dotnet nuget locals all --clear delete?

It clears the global-packages folder, http-cache, temp cache, and plugins-cache. All downloaded packages are removed and re-downloaded on next restore. This is the NuGet equivalent of clearing browser cache.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro