.NET "error NETSDK1045: current SDK does not support targeting" in CI
The project targets a .NET version newer than the SDK installed on the runner. NETSDK1045 means you must install a matching (or newer) SDK, because an SDK cannot build a framework it predates.
What this error means
dotnet build fails with "error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0."
dotnet
error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.
Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0.Common causes
The runner SDK is older than the target framework
The image or setup-dotnet step provides an SDK that predates the TargetFramework, so it cannot build it.
A global.json pins an older SDK
A global.json rolls the SDK down to a version that does not support the project's framework.
How to fix it
Install the matching SDK in CI
- Set
setup-dotnetto the SDK major that supports the target framework. - Remove or update a
global.jsonthat pins an older SDK. - Re-run the build.
.github/workflows/ci.yml
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'Align global.json with the target
If you keep a global.json, set it to an SDK that supports the framework.
global.json
{
"sdk": { "version": "8.0.100", "rollForward": "latestFeature" }
}How to prevent it
- Provision the SDK major that matches your target framework in CI.
- Keep
global.jsonin step with the frameworks you build. - Pin
setup-dotnetversions so the SDK is deterministic.
Related guides
.NET "A compatible .NET SDK was not found" (global.json) in CIFix "A compatible .NET SDK was not found" / "Requested SDK version ... was not found" in CI - global.json pin…
MSBuild "error MSB3644: reference assemblies not found" in CIFix "error MSB3644: The reference assemblies for .NETFramework,Version=vX were not found" in CI - the targeti…
.NET "error NETSDK1047: Assets file does not have a target for RID" in CIFix "error NETSDK1047: Assets file does not have a target for net8.0/RID" during dotnet publish in CI - the p…