/codes/nuget/nuget-error-codes
NuGet error and warning codes: NU1101, NU1102, NU1301, NU1605, NU1608, NU1701, NU1903
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
- tool
- NuGet
- versions
- .NET 6 – 10 SDK, NuGet 6.x – 7.x
- os
- any
NuGet prefixes every restore problem with an NU code. Codes from NU1100 to NU1199 are resolution failures (the package or version cannot be found or does not fit), NU13xx are feed and network problems, NU16xx are warnings about the resolved graph (downgrades, approximate matches, versions outside a dependency's range), NU17xx are compatibility warnings, and NU190x report known vulnerabilities. With TreatWarningsAsErrors, any warning code also fails the build.
Three codes from one restore
cat > nuget.config <<'EOF'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
EOF
cat > App.csproj <<'EOF'
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Jsonn" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="99.0.0" />
</ItemGroup>
</Project>
EOF
echo "--- nuget.org"
dotnet restore 2>&1 | grep -oE "error NU110[12]: Unable to find package [^[]*" | sed 's/ *$//' | sort -u
echo "--- a feed that does not answer"
cat > nuget.config <<'EOF'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="offline" value="https://127.0.0.1:4720/v3/index.json" />
</packageSources>
</configuration>
EOF
dotnet restore 2>&1 | grep -oE "error NU1301: Unable to load the service index for source [^ ]+" | sort -u
exit "${PIPESTATUS[0]}"Output · exit 1
--- nuget.org error NU1101: Unable to find package Newtonsoft.Jsonn. No packages exist with this id in source(s): nuget.org error NU1102: Unable to find package Newtonsoft.Json with version (>= 99.0.0) --- a feed that does not answer error NU1301: Unable to load the service index for source https://127.0.0.1:4720/v3/index.json.
Code table
| Code | Level | Meaning | Usual fix |
|---|---|---|---|
| NU1100 | Error | Unable to resolve a dependency (often no sources configured) | Check nuget.config and dotnet nuget list source |
| NU1101 | Error | No source has a package with this id | Fix the id or add the feed |
| NU1102 | Error | The package exists, but no version matches the range | Use a version that exists |
| NU1103 | Error | Only prerelease versions match a stable range | Reference the prerelease explicitly |
| NU1107 | Error | Version conflict between two dependency paths | Reference the package directly at a version both accept |
| NU1108 | Error | Cycle in the dependency graph | Remove the circular reference |
| NU1202 | Error | Package not compatible with the target framework | Use a package version that supports it, or change TargetFramework |
| NU1301 | Error | Unable to load the service index for a source (network, TLS, auth) | Check the URL, proxy and credentials, or disable the source |
| NU1603 | Warning | The exact lower bound was not found; a higher version was used | Pin a version that exists |
| NU1605 | Warning (error by default in SDK projects) | Detected package downgrade | Reference the higher version directly |
| NU1608 | Warning | Resolved version is outside a dependency constraint | Align versions or upgrade the dependent package |
| NU1701 | Warning | Package restored with a .NET Framework fallback target | Look for a package version built for your framework |
| NU1900 | Warning | Vulnerability data could not be downloaded | Check access to the audit source |
| NU1901 – NU1904 | Warning | Package with a known low, moderate, high or critical vulnerability | Upgrade to a patched version |
Promoting or silencing codes
<PropertyGroup>
<!-- fail the build on high and critical vulnerabilities -->
<WarningsAsErrors>$(WarningsAsErrors);NU1903;NU1904</WarningsAsErrors>
<!-- accept a known framework fallback -->
<NoWarn>$(NoWarn);NU1701</NoWarn>
</PropertyGroup>Scope NoWarn to a single package with <PackageReference Include="X" Version="1.0.0" NoWarn="NU1701" /> instead of the whole project when possible.
Sources
- learn.microsoft.comlearn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1101
- learn.microsoft.comlearn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1102
- learn.microsoft.comlearn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1301
- learn.microsoft.comlearn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1605
- learn.microsoft.comlearn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1608
- learn.microsoft.comlearn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1701
- learn.microsoft.comlearn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1903
Related pages
errors · nugeterror NU1101: Unable to find package X. No packages exist with this id in source(s): nuget.orgNU1101 means no configured NuGet source has a package with that id: a typo, a private feed missing from nuget.config, or a disabled source. Fix the id or feed.errors · nugeterror NU1102: Unable to find package X with version (>= Y)NU1102 means the package exists but no configured source has a version in the requested range: a typo, a prerelease, or a lagging feed. Use a real version.config · nugetnuget.config packageSources: add a private feed and clear the defaultspackageSources in nuget.config lists the feeds NuGet restores from. Use clear to drop inherited ones, add a private feed, check with dotnet nuget list source.flags · nugetdotnet restore --locked-mode: fail when packages.lock.json does not matchdotnet restore --locked-mode restores only what packages.lock.json says and fails with NU1004 when references changed. Enabling lock files, CI setup, pitfalls.