NU1101 dotnet build_error ai_generated true

错误 NU1101: 无法找到包 'PackageName'。在源 nuget.org、local-cache 中不存在具有此 ID 的包。

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

其他格式: JSON · Markdown 中文 · English
92%修复率
89%置信度
1证据数
2023-02-05首次发现

版本兼容性

版本状态引入弃用备注
dotnet 6.0 active
dotnet 8.0 active
NuGet 6.0 active
NuGet 6.8 active

根因分析

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

English

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

generic

官方文档

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

解决方案

  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:

无效尝试

常见但无效的做法:

  1. 80% 失败

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

  2. 95% 失败

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

  3. 70% 失败

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