Error Knowledge Base NuGet NU1202

NU1202: Package is not compatible with the target framework

The selected package version does not contain lib or ref assets compatible with one of your project’s target frameworks or platforms.

Fix it fast

Most likely: The package version NuGet selected does not ship assets for the target framework shown in the error, such as net8.0, netstandard2.0, or a platform TFM.

1. Confirm this is your error
error NU1202: Package Some.Package 1.2.3 is not compatible with net8.0.
2. Check the cause
dotnet restore -v normal
grep -n "<TargetFramework\|<TargetFrameworks\|<PackageReference" *.csproj
dotnet list package --include-transitive
3. Apply the safe fix
# Upgrade the package to a version that supports the failing target framework.
dotnet add package <package-id> --version <compatible-version>

# If only one target framework fails, use a conditional PackageReference or adjust TargetFrameworks intentionally.
dotnet restore
dotnet build
4. Verify it works
dotnet restore
dotnet build
dotnet test
Don't use unsafe shortcuts
  • Do not change TargetFramework just to silence the error unless the app really should target that framework.
  • Do not assume a newer package supports older TFMs, check the package assets for the TFM in the error.
  • Do not ignore multi-target failures because one target framework restored successfully.

What Broke in the Dependency Graph

The selected package version does not contain lib or ref assets compatible with one of your project’s target frameworks or platforms.

Repair the dependency graph

Choose a package version that supports your TFM by upgrading the package or its parents.

If multi-targeting, conditionally reference packages per TFM or adjust TargetFrameworks.

Re-run restore:dotnet restore

Validation

Re-run the failing command and confirm the original code/message is gone, and confirm expected artifacts or outputs exist (packages restored, build/publish succeeds).

Why Resolution Broke

Usually this comes down to the selected package version doesn’t support your TFM or platform TFM, one TFM in TargetFrameworks is unsupported even if others work, or a transitive dependency forces an older package version without your TFM.

Prove the Graph Is Clean Again

dotnet restore succeeds across all TFMs, and dotnet build or dotnet test succeeds for the previously failing TFM.

Mechanism

NuGet selects a package version, then picks the best lib or ref assets for each TargetFramework. If no compatible assets exist for a TFM, restore fails with NU1202.

Keep the Dependency Graph Healthy

To prevent this, upgrade dependencies alongside runtime and TFM upgrades, and continuously validate multi-target builds in CI.

Docs and source code

NU1202 compatibility failure message

Message template for incompatible TFM assets. - GitHub

  <data name="Log_PackageNotCompatibleWithFx" xml:space="preserve">
    <value>Package {0} {1} is not compatible with {2}.</value>
    <comment>0 - package id, 1 - version, 2 - target framework</comment>
  </data>
  <data name="Log_PackagesAndProjectsAreCompatible" xml:space="preserve">

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list