Troubleshooting SDK Errors
|
This section documents MSBuild 18.9, the .NET SDK 10.0.402 (with its 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
-
Read the code and open its page —
https://learn.microsoft.com/dotnet/core/tools/sdk-errors/netsdkNNNN, or theaka.mslink many messages include. -
Check which SDK ran.
dotnet --versionin the folder the command ran from, anddotnet --infofor the SDK, MSBuild and workload versions and whetherglobal.jsonwas valid (Installing and Selecting SDKs). -
Restore with the same options as the build. Most assets-file errors are a restore for a different framework, RID or property set.
-
Query the inputs with
dotnet msbuild -getProperty:TargetFrameworks -getProperty:RuntimeIdentifier …. -
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).
Source: .NET SDK error list.
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.
Source: NETSDK1004, NETSDK1005 and NETSDK1047.
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).
Source: NETSDK1100, NETSDK1135, NETSDK1083.
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 |
NETSDK1022 |
Duplicate 'Compile' items were included. … The duplicate items were: 'Ledger.cs' |
A |
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 |
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).
Source: NETSDK1022, NETSDK1045, NETSDK1141.
Common mistakes
-
Fixing the project when the SDK is wrong — check
dotnet --versionfirst. -
--no-restoreafter 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.