Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

NETSDK1045: The current .NET SDK does not support targeting .NET 9.0

The requested target framework is newer than the SDK that runs the build. Check the resolved SDK, the global.json pin, and the container image tag.

~5 min readC#
#.NET#C##CI#Tooling
A dotnet target framework crate demanding net nine, amber older SDK crate and cyan global json key

Introduction & Quick Summary

text
error NETSDK1045: The current .NET SDK does not support targeting .NET 9.0. Either target .NET 8.0 or lower, or use a version of the .NET SDK that supports .NET 9.0.

The project asks for a target framework newer than the SDK that is running the build. The message names both sides, and the fix is on the SDK side unless the target framework was bumped by mistake.

Why the SDK ends up older than the target:

  • global.json pins an older SDK. A repository-wide pin keeps CI on 8.0.100 while the project moved to net9.0.
  • Only the older SDK is installed. Changing TargetFramework does not install anything; the build finds what is on the machine.
  • The build host is a Docker image or a CI runner with a fixed SDK line. mcr.microsoft.com/dotnet/sdk:8.0 cannot build net9.0.
  • A second SDK is installed but not selected. Several SDKs coexist, and the resolver picks by global.json, then by the highest installed version.
MessageMeaningFix
does not support targeting .NET 9.0SDK older than the requested TFMInstall a 9.x SDK
Either target .NET 8.0 or lowerThe same failure, with the fallback namedAlign the TFM or the SDK
NETSDK1147Workload missingdotnet workload install
NU1202Package does not support the TFMAlign the package version
Could not load file or assembly at runtimeBuilt for the installed runtime, not the targeted onePublish with the right runtime

Core Mechanics, Signatures & Reproducible Setup

The SDK resolves in three steps: a global.json in the current directory or any parent selects a version (or a range, with rollForward), an installed SDK matching the selection is used, and otherwise the highest installed SDK is used. The target framework in the project file must be supported by that SDK. An SDK supports its own major version and all older ones, so SDK 9 builds net8.0 and net7.0, but SDK 8 never builds net9.0.

A reproduction is a project with one line changed:

xml
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net9.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup> </Project>
bash
dotnet --version # 8.0.404 dotnet build # error NETSDK1045: The current .NET SDK does not support targeting .NET 9.0.
bash
dotnet --list-sdks # 8.0.404 [/usr/share/dotnet/sdk] # 9.0.100 [/usr/share/dotnet/sdk] dotnet --version # 9.0.100

Installing the newer SDK is enough when no global.json is present, because the resolver then takes the highest version installed.

Key Comparison Table

An SDK supports its own TFM and older ones. The matrix is short and explains most of these reports.

SDK installednet8.0net9.0net10.0
8.0.404YesNETSDK1045NETSDK1045
9.0.100YesYesNETSDK1045
10.0.100YesYesYes
8 and 9 side by sideYesYes, highest winsNETSDK1045

global.json decides which of several installed SDKs runs, and rollForward decides how strict the pin is.

rollForwardMeaningEffect of a pinned 8.0.100 with 9.0.100 installed
disableExact version onlyBuild fails if 8.0.100 is missing
patchSame feature band, latest patchStays on 8.0.1xx
featureNext feature band, same minorMay move to 8.0.4xx
minorNext minor versionMoves to 8.0.x, not 9.x
latestPatchLatest patch of the pinned minorStays in 8.0
latestMinorLatest minor of the pinned majorLatest 8.0.x
latestMajorLatest installed majorMoves to 9.0.100

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

Read the resolved SDK, not the installed list

dotnet --list-sdks shows what exists; dotnet --version shows what runs. In a repository the difference is usually a global.json above the project directory.

bash
dotnet --version dotnet --list-sdks dotnet --info | head -20
bash
# find the global.json that is actually in effect while [ "$PWD" != "/" ]; do [ -f global.json ] && echo "$PWD/global.json"; cd ..; done

The walk upward is what dotnet does, so a pin in a parent directory applies even when the project has none.

Update a pin deliberately

Changing a pin changes the build for everyone, so choose the narrowest roll-forward that satisfies the project and commit the reason.

{ "sdk": { "version": "9.0.100", "rollForward": "latestFeature", "allowPrerelease": false } }
{ "sdk": { "version": "9.0.100", "rollForward": "latestMinor" } }

latestFeature allows patch and feature-band updates within 9.0, which is the usual choice for a service. latestMajor is convenient for local development and risky in CI, because it silently changes the compiler on a new SDK release.

Align a Docker build

The SDK image tag fixes the build environment. A net9.0 project needs an SDK 9 image, and the runtime image must match the target framework.

dockerfile
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /src COPY *.csproj ./ RUN dotnet restore COPY . . RUN dotnet publish -c Release -o /app FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final WORKDIR /app COPY --from=build /app . ENTRYPOINT ["dotnet", "App.dll"]
bash
docker build -t app . && docker run --rm app dotnet --info | head -5

A global.json inside the image that pins 8.0 produces NETSDK1045 even with the 9.0 SDK image, because the pin wins.

CI runners with a fixed SDK line

Hosted runners ship one or two SDK lines and change them on their own schedule. Pin the SDK in the workflow, not in a comment, and verify the version after setup.

- uses: actions/setup-dotnet@v4 with: dotnet-version: | 8.0.x 9.0.x - run: dotnet --version && dotnet build --configuration Release
# install locally without touching the global install curl -sSL https://dot.net/v1/dotnet-install.sh | bash -s -- --channel 9.0 --install-dir "$HOME/.dotnet" export PATH="$HOME/.dotnet:$PATH" dotnet --version

Installing into a private directory avoids permission problems on shared machines and makes the version visible in the job log.

Visual Studio and the SDK it uses

Visual Studio has its own SDK resolution and reports the same error with a different dialog. Installing the SDK separately is not always enough; the VS installer component must be present for the IDE's build.

bash
dotnet --list-sdks where dotnet # Windows which dotnet # macOS, Linux
text
# a mismatched SDK in a solution directory is the usual cause C:\repo\global.json -> 8.0.100 C:\repo\src\App\App.csproj -> net9.0

Deleting or updating the solution-root global.json fixes the IDE without reinstalling anything.

Target framework versus runtime

A successful build does not guarantee the runtime can start the app. dotnet publish with --self-contained or a runtime identifier embeds the runtime, while a framework-dependent publish needs the matching runtime installed.

bash
dotnet publish -c Release -r linux-x64 --self-contained false -o out dotnet --list-runtimes cat out/App.runtimeconfig.json

runtimeconfig.json names the required framework version. A server with only 8.0 installed and an app requiring 9.0 fails at startup with a framework-not-found message, which is the runtime counterpart of NETSDK1045.

Common Compilation/Runtime Mistakes & Version Gotchas

Lowering TargetFramework to silence the error. It builds, but packages and APIs written for 9.0 then fail with NU1202 or missing types. Install the SDK instead.

Editing the wrong global.json. The one nearest the working directory wins, and a solution-root file overrides a project-level one. Search upward before changing anything.

Assuming dotnet --list-sdks matters. A 9.0 SDK can be installed and unused because the pin selects 8.0. dotnet --version is the resolved answer.

Using rollForward: "latestMajor" in a shared repository. The build changes when a new major SDK appears on the runner, which is exactly the surprise a pin exists to prevent.

Forgetting the runtime image. The build succeeds and the container exits with a framework-missing error, because the runtime tag was left at the previous major.

Version notes. rollForward replaced the older rollForwardOnNoCandidateFx setting in .NET Core 3.0. .NET 9 and .NET 10 both allow net8.0 projects to build with their SDK, and multi-targeting (<TargetFrameworks>net8.0;net9.0</TargetFrameworks>) requires an SDK for the newest listed framework. The NETSDK1045 text is stable across versions, so search results for older .NET Core releases describe the same cause.

Order: dotnet --version, find the effective global.json, install or select the matching SDK, then align the container and CI images. When the pin file is the suspect, the JSON formatter makes the sdk block readable next to the project file, and the env reader confirms which DOTNET_ROOT the build shell is actually using.

Official references: global.json overview and NETSDK1045.

Official references

primary documentation

The C# documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit C# work — they run entirely in this browser tab, so nothing you paste leaves your device.

All C# guides

More in C#

All C# guides

The guides filed next to this one in C#, in library order.