NuGet "NU1608: Detected package version outside of dependency constraint"
NuGet resolved a package to a version that sits outside the range a dependency declared it supports. It warns with NU1608 - benign by default, but a build-breaker under warnings-as-errors.
What this error means
Restore prints NU1608 saying a package’s resolved version is outside another package’s declared constraint (e.g. a dependency expects < 7.0.0 but 7.0.1 was resolved). It only fails the build where NuGet warnings are treated as errors.
warning NU1608: Detected package version outside of dependency constraint:
SomeLib 2.0.0 requires Newtonsoft.Json (>= 11.0.1 && < 13.0.0) but version
Newtonsoft.Json 13.0.3 was resolved.Common causes
A direct pin overrides a dependency’s upper bound
You (or another chain) pinned a higher version than a dependency declared support for, so NuGet uses the higher version but warns it is outside the constraint.
Warnings promoted to errors
NU1608 is informational by default. A warnings-as-errors policy turns the out-of-range resolution into a hard failure.
How to fix it
Align to a version inside the constraint
Pin a version both the dependency and your project accept, or upgrade the dependency to one that supports the higher version.
dotnet list package --include-transitive
# pin a compatible version, or upgrade SomeLib to a release that allows 13.xSuppress NU1608 only when the override is verified
When the higher version is known-compatible, suppress narrowly rather than disabling all NuGet warnings.
<PropertyGroup>
<NoWarn>$(NoWarn);NU1608</NoWarn>
</PropertyGroup>How to prevent it
- Keep direct pins within the ranges your dependencies declare.
- Upgrade dependencies together so their constraints stay compatible.
- Use
NoWarnfor specific codes rather than turning warnings-as-errors off.