NU1101 dotnet build_error ai_generated true

error NU1101: Unable to find package 'PackageName'. No packages exist with this id in source(s): nuget.org, local-cache

ID: dotnet/nuget-package-restore-failure

Also available as: JSON · Markdown · 中文
92%Fix Rate
89%Confidence
1Evidence
2023-02-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
dotnet 6.0 active
dotnet 8.0 active
NuGet 6.0 active
NuGet 6.8 active

Root Cause

NuGet package restore cannot locate the specified package in any configured package source, either due to typo, missing package, or source misconfiguration.

generic

中文

NuGet 包还原在任何配置的包源中都找不到指定的包,可能是由于拼写错误、包缺失或源配置错误。

Official Documentation

https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1101

Workarounds

  1. 90% success Verify the package name and version in the .csproj file. Use dotnet list package --outdated to check available versions.
    Verify the package name and version in the .csproj file. Use dotnet list package --outdated to check available versions.
  2. 85% success Add the correct NuGet source (e.g., private feed) using dotnet nuget add source. Example:
    Add the correct NuGet source (e.g., private feed) using dotnet nuget add source. Example:
  3. 80% success If the package is internal, build and pack it first, then reference the local .nupkg file. Example:
    If the package is internal, build and pack it first, then reference the local .nupkg file. Example:

中文步骤

  1. Verify the package name and version in the .csproj file. Use dotnet list package --outdated to check available versions.
  2. Add the correct NuGet source (e.g., private feed) using dotnet nuget add source. Example:
  3. If the package is internal, build and pack it first, then reference the local .nupkg file. Example:

Dead Ends

Common approaches that don't work:

  1. 80% fail

    If the package doesn't exist in the source, clearing cache won't help; it just re-downloads the same error.

  2. 95% fail

    May introduce untrusted packages or malware; doesn't solve the missing package issue.

  3. 70% fail

    NuGet restore may still try to fetch from configured sources and ignore local files if not properly referenced.