dotnet "The framework Microsoft.NETCore.App was not found"
A built app tried to run but the .NET runtime version it targets is not installed. The host lists the frameworks it does have and exits, because it cannot run on a runtime that is absent.
What this error means
Running the app (or a tool, or dotnet test) fails with "The framework Microsoft.NETCore.App, version x was not found", listing the installed runtimes. Building may have worked; running does not.
You must install or update .NET to run this application.
App: /app/MyApp.dll
Framework: 'Microsoft.NETCore.App', version '8.0.0' (x64)
The following frameworks were found:
6.0.27 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]Common causes
The target runtime is not installed
The app targets a runtime version (e.g. 8.0) but the runner or container only has an older one. Building with the SDK does not guarantee the matching runtime exists at run time.
Runtime image older than the build target
A multi-stage Docker build compiled against 8.0 but the final stage uses a 6.0 runtime image, so the published app has no matching framework to run on.
How to fix it
Install the matching runtime
Add the runtime version the app targets to the runner.
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x' # installs the 8.0 runtime + SDKAlign the runtime image to the build target
In Docker, make the final stage’s runtime image match the TargetFramework you built against.
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "MyApp.dll"]Or publish self-contained
A self-contained publish bundles the runtime so no framework needs to be installed on the host.
dotnet publish -c Release -r linux-x64 --self-contained trueHow to prevent it
- Match the runtime image/version to your project’s
TargetFramework. - Install the runtime, not just the SDK, where you run the app.
- Consider self-contained publishes for minimal or pinned runtime environments.