Troubleshooting SDK Errors

This section documents MSBuild 18.9, the .NET SDK 10.0.402 (with its dotnet CLI) and NuGet 7.9, as published in the MSBuild, .NET and NuGet documentation on learn.microsoft.com, which is the reference these pages are written and verified against. Material about .NET 11 / NuGet 8.0 is still in preview and is always flagged as such — never presented as baseline.

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

The C# Reference bibliography lists the reference material consulted while preparing these pages.

Errors and warnings from the .NET SDK’s own build logic carry NETSDK codes, each with a documentation page. Most come from four causes: the wrong SDK, a restore that does not match the build, a framework or runtime the machine cannot target, and project-file mistakes. This page gives a method and the real messages of the common ones with .NET SDK 10.0.402. MSBuild’s own errors are on Troubleshooting MSBuild and NuGet’s on Troubleshooting NuGet Errors and Warnings.

A diagnosis method

  1. Read the code and open its page — https://learn.microsoft.com/dotnet/core/tools/sdk-errors/netsdkNNNN, or the aka.ms link many messages include.

  2. Check which SDK ran. dotnet --version in the folder the command ran from, and dotnet --info for the SDK, MSBuild and workload versions and whether global.json was valid (Installing and Selecting SDKs).

  3. Restore with the same options as the build. Most assets-file errors are a restore for a different framework, RID or property set.

  4. Query the inputs with dotnet msbuild -getProperty:TargetFrameworks -getProperty:RuntimeIdentifier ….

  5. Record a binary log (-bl) when the cause is not obvious.

For a bug report to the SDK or a library, include the full dotnet --info output, the command line and the binary log (after checking it for secrets: binary logs contain environment variables and property values).

Assets file errors: NETSDK1004, NETSDK1005, NETSDK1047

All three mean obj/project.assets.json — written by restore — does not describe what the build is asked to do.

error NETSDK1004: Assets file '~/ledgerline/samples/Ledgerline.Report/obj/project.assets.json' not found. Run a NuGet package restore to generate this file.

NETSDK1004: no restore at all (a --no-restore build of a fresh clone).

A restored single-target project was changed to <TargetFrameworks>net10.0;net8.0</TargetFrameworks> and built with --no-restore:

~/.dotnet/sdk/10.0.402/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1005: Assets file '~/sdkerr/E1005/obj/project.assets.json' doesn't have a target for 'net8.0'. Ensure that restore has run and that you have included 'net8.0' in the TargetFrameworks for your project. [~/sdkerr/E1005/E1005.csproj::TargetFramework=net8.0]

Restored without a RID and built with -r linux-x64 --no-restore:

~/.dotnet/sdk/10.0.402/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(266,5): error NETSDK1047: Assets file '~/sdkerr/E1005/obj/project.assets.json' doesn't have a target for 'net10.0/linux-x64'. Ensure that restore has run and that you have included 'net10.0' in the TargetFrameworks for your project. You may also need to include 'linux-x64' in your project's RuntimeIdentifiers.

The fix in each case is a restore with the same frameworks and RID (dotnet restore -r linux-x64), or a build without --no-restore. Projects that are always built for some RIDs can list them in RuntimeIdentifiers so one restore covers them.

Platform errors: NETSDK1100, NETSDK1135, NETSDK1083

A Windows Forms project (net10.0-windows, UseWindowsForms) built on Linux:

~/.dotnet/sdk/10.0.402/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(120,5): error NETSDK1100: To build a project targeting Windows on this operating system, set the EnableWindowsTargeting property to true. [~/sdkerr/E1100/E1100.csproj]

EnableWindowsTargeting=true lets Linux and macOS CI build (not run) Windows projects. A plain net10.0-windows console project without UseWindowsForms/UseWPF built without the error, because it needs no Windows-only targeting pack.

A minimum OS version above the targeted one:

<TargetFramework>net10.0-windows10.0.19041.0</TargetFramework>
<SupportedOSPlatformVersion>10.0.22621.0</SupportedOSPlatformVersion>
~/.dotnet/sdk/10.0.402/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(243,5): error NETSDK1135: SupportedOSPlatformVersion 10.0.22621.0 cannot be higher than TargetPlatformVersion 10.0.19041.0. [~/sdkerr/E1135/E1135.csproj]

A distribution-specific RID, which the portable RID graph of .NET 8 and later does not know:

<sdk>/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(190,5): error NETSDK1083: The specified RuntimeIdentifier 'ubuntu.22.04-x64' is not recognized. See https://aka.ms/netsdk1083 for more information. [~/demo/App.csproj]

Use portable RIDs (linux-x64, linux-musl-x64, win-arm64) (Target Frameworks and Runtime Identifiers).

NETSDK1206: packages with distribution-specific assets

The same RID change affects packages. SQLitePCLRaw.bundle_e_sqlite3 2.1.4 ships native libraries for alpine-* RIDs:

~/.dotnet/sdk/10.0.402/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(308,5): warning NETSDK1206: Found version-specific or distribution-specific runtime identifier(s): alpine-arm, alpine-arm64, alpine-x64. Affected libraries: SQLitePCLRaw.lib.e_sqlite3. In .NET 8.0 and higher, assets for version-specific and distribution-specific runtime identifiers will not be found by default. See https://aka.ms/dotnet/rid-usage for details. [~/sdkerr/E1206/E1206.csproj]
~/sdkerr/E1206/E1206.csproj : warning NU1903: Package 'SQLitePCLRaw.lib.e_sqlite3' 2.1.4 has a known high severity vulnerability, https://github.com/advisories/GHSA-2m69-gcr7-jv3q

On Alpine Linux the app would not find its native SQLite library. The fix is a newer package that uses portable RIDs (linux-musl-x64) — which, here, NuGet’s vulnerability audit (NU1903) also asks for.

Source: NETSDK1206.

Error table

Code Message (abridged) Cause and fix

NETSDK1004

Assets file '…/project.assets.json' not found.

Restore first.

NETSDK1005

Assets file … doesn’t have a target for 'net8.0'.

Restore after changing target frameworks.

NETSDK1047

… doesn’t have a target for 'net10.0/linux-x64'.

Restore with the same -r.

NETSDK1022

Duplicate 'Compile' items were included. … The duplicate items were: 'Ledger.cs'

A Compile Include that repeats the default glob; remove it (SDK-Style Project Files).

NETSDK1045

The current .NET SDK does not support targeting .NET 11.0.

Install and select a newer SDK (Restore, Build and Clean).

NETSDK1083

The specified RuntimeIdentifier 'ubuntu.22.04-x64' is not recognized.

Use a portable RID.

NETSDK1100

To build a project targeting Windows on this operating system, set the EnableWindowsTargeting property to true.

Set it for non-Windows CI.

NETSDK1135

SupportedOSPlatformVersion 10.0.22621.0 cannot be higher than TargetPlatformVersion 10.0.19041.0.

Raise the TFM’s platform version or lower the minimum.

NETSDK1141

Unable to resolve the .NET SDK version as specified in the global.json located at …

Text from the documentation; the dotnet CLI here reported "A compatible .NET SDK was not found" instead (Installing and Selecting SDKs).

NETSDK1206

Found version-specific or distribution-specific runtime identifier(s): …

Update the package.

Others shown on other pages: NETSDK1138 (out-of-support target framework), NETSDK1147 (missing workload, Workloads), NETSDK1194 (--output with a solution).

Common mistakes

  • Fixing the project when the SDK is wrong — check dotnet --version first.

  • --no-restore after changing frameworks or RIDs — NETSDK1005/1047.

  • Distribution-specific RIDs from old guides — NETSDK1083 and NETSDK1206.

  • Posting a binary log publicly without reviewing it — it contains environment variables.