Skip to content
Latchkey

.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

  1. Set setup-dotnet to the SDK major that supports the target framework.
  2. Remove or update a global.json that pins an older SDK.
  3. 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.json in step with the frameworks you build.
  • Pin setup-dotnet versions so the SDK is deterministic.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →