dotnet says it cannot find any installed .NET SDKs (in Docker or on a server)
It was not possible to find any installed .NET Core SDKsShort 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.
Fix it fast
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-runtimes2Match what you see, then jump to its fix
- 1
dotnet --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
dotnet --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
The 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
- 1
What does the error look like?
It was not possible to find any installed .NET Core SDKsA 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" Dockerfile2Fix
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
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-sdks2Fix
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 --versionConfirmed by learn.microsoft.com
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/dotnet2Fix
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-sdksConfirmed by learn.microsoft.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- RaheebA consumer app shipped to both stores from one Flutter codebase on a .NET and Azure back end.
Related fixes
Servers
A containerized ASP.NET Core app says the framework Microsoft.AspNetCore.App was not found
Framework: 'Microsoft.AspNetCore.App', version '6.0.0' (x64)
The app asks for a shared framework the final image does not have.
3 causes, each with a fixServers
Playwright for .NET cannot find the browser inside a Docker container
Microsoft.Playwright.PlaywrightException: Executable doesn't exist
The container has no browser build that matches the Playwright NuGet package your code uses.
3 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
sam local fails: Running AWS SAM projects locally requires Docker
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
sam local start-api and sam local invoke run your function inside a Docker container, so SAM stops if it cannot talk to Docker.
3 causes, each with a fixServers
dnf fails to download repo metadata in a CentOS 8 Docker build
The same Dockerfile built fine before 2022
CentOS Linux 8 reached end of life on 31 December 2021 and its content left the mirrors.
2 causes, each with a fixServers
pip install confluent-kafka fails because librdkafka/rdkafka.h is missing
pip stops while building confluent-kafka from source
The error means pip is compiling confluent-kafka from source, and the compiler cannot find the librdkafka C headers.
3 causes, each with a fix