Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

dotnet says it cannot find any installed .NET SDKs (in Docker or on a server)

ErrorIt was not possible to find any installed .NET Core SDKs

Short answer

The dotnet command found a runtime but no SDK that fits. Run dotnet --list-sdks to see what exists. In Docker it is usually a runtime image used for build commands; elsewhere a global.json asks for an SDK version that is not installed, or the SDK lives outside the folder dotnet searches.

  • Applies to .NET 8, .NET 9, .NET 10, Docker Engine 28, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List the SDKs and runtimes this dotnet can see, in the same shell, container or CI step that fails.

    dotnet --list-sdks
    dotnet --list-runtimes
  2. 2Match what you see, then jump to its fix

    1. 1dotnet --list-sdks is empty inside the container, and the command that fails is dotnet build, restore, publish or newA runtime image is used to run SDK commandsFix
    2. 2dotnet --list-sdks lists SDKs, but a global.json in the repository names another versionglobal.json asks for an SDK version that is not installedFix
    3. 3The SDK files exist on disk (for example from a manual install), but dotnet --list-sdks does not show themThe SDK is installed in a folder the host does not searchFix

What does the error look like?

  • It was not possible to find any installed .NET Core SDKs
  • A compatible .NET SDK was not found

Cause 1 of 3

A runtime image is used to run SDK commands

1Check

The sdk image holds the SDK, and the aspnet and runtime images hold only what is needed to run an app. Look at the FROM line of the stage that runs the command.

grep -n "^FROM" Dockerfile

2Fix

Build in a stage based on the sdk image, and copy only the published output into a final stage based on aspnet (or runtime). Use the same major version in both.

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /App
COPY . ./
RUN dotnet restore
RUN dotnet publish -o out

FROM mcr.microsoft.com/dotnet/aspnet:9.0
WORKDIR /App
COPY --from=build /App/out .
ENTRYPOINT ["dotnet", "MyApp.dll"]

3Verify

Rebuild the image. The build stage now finds an SDK.

docker build --progress=plain -t my-app .

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 3

global.json asks for an SDK version that is not installed

1Check

The version field needs a full version number and rollForward decides what else is acceptable. With no rollForward value, the default is patch, which accepts only later patches of the same feature band.

cat global.json
dotnet --list-sdks

2Fix

Install the SDK that global.json names, or allow a newer installed one with a roll-forward policy such as latestFeature.

{
  "sdk": {
    "version": "10.0.100",
    "rollForward": "latestFeature"
  }
}

3Verify

The SDK resolves and the CLI prints its version.

dotnet --version

Confirmed by learn.microsoft.com

Did this fix it?

Cause 3 of 3

The SDK is installed in a folder the host does not search

1Check

The host looks in the default install location, which varies by distribution and install method on Linux. DOTNET_ROOT names another location.

echo "$DOTNET_ROOT"
ls /usr/share/dotnet /usr/lib/dotnet

2Fix

Point DOTNET_ROOT at the folder that holds the dotnet host and its sdk folder, or reinstall into the default location.

export DOTNET_ROOT=/opt/dotnet
export PATH="$PATH:$DOTNET_ROOT"

3Verify

dotnet --list-sdks now shows the installed SDK.

dotnet --list-sdks

Confirmed by learn.microsoft.com

Did this fix it?

How do I stop it coming back?

  • Use a multi-stage Dockerfile: sdk image to build, aspnet or runtime image to run.
  • In CI, pin the SDK with global.json and a rollForward policy, and install the same version in the pipeline.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.