Skip to content
Latchkey

ASP.NET Core TargetFramework mismatch (NETSDK1045) in CI

The .NET SDK installed on the runner is older than the TargetFramework your project declares, so the SDK refuses to build it. Install the matching SDK with setup-dotnet (or global.json) so CI targets the same framework you do locally.

What this error means

The 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."

.NET
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 TargetFramework

CI provisioned an SDK that predates net8.0 (or whatever you target), so it cannot build the project.

global.json pins an SDK CI does not have

A global.json requests an SDK version not installed on the runner, so the resolved SDK is too old for the target.

How to fix it

Install the matching SDK with setup-dotnet

  1. Add setup-dotnet with the version your TargetFramework needs.
  2. Match dotnet-version to the SDK band for your target (for net8.0 use 8.0.x).
  3. Commit a global.json if you need an exact SDK across environments.
.github/workflows/ci.yml
- uses: actions/setup-dotnet@v4
  with:
    dotnet-version: '8.0.x'

Align global.json with an available SDK

Pin an SDK version that setup-dotnet installs, or allow roll-forward so a compatible SDK is used.

global.json
{
  "sdk": { "version": "8.0.400", "rollForward": "latestFeature" }
}

How to prevent it

  • Install the SDK band that matches your TargetFramework with setup-dotnet.
  • Keep global.json in sync with the SDK CI actually provisions.
  • Do not rely on launchSettings.json in CI; it is a local dev file, not read by the build.

Frequently asked questions

What causes ""NETSDK1045 ... does not support targeting""?
CI provisioned an SDK that predates net8.0 (or whatever you target), so it cannot build the project.
How do I fix "NETSDK1045 ... does not support targeting"?
Install the matching SDK with setup-dotnet

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card