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.
ID: dotnet/build-failed-sdk-mismatch
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 8 | active | — | — | — |
Root Cause
SDK version mismatch build failures occur when the installed .NET SDK does not support the target framework specified in the project. Caused by global.json pinning to an unavailable SDK version, outdated SDK installations, or CI environments with the wrong SDK. Fix by installing the correct SDK version or updating global.json.
genericWorkarounds
-
95% success Install the correct .NET SDK version specified in global.json or required by the project
Check the required version: cat global.json or look at <TargetFramework> in .csproj. Download and install from https://dotnet.microsoft.com/download or use the dotnet-install script: curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 8.0.xxx. Verify with 'dotnet --list-sdks'
-
88% success Update global.json to use rollForward policy
Edit global.json to add a rollForward policy that allows newer patch or feature band versions: { "sdk": { "version": "8.0.100", "rollForward": "latestFeature" } }. The 'latestFeature' policy allows any 8.0.xxx SDK, while 'latestPatch' restricts to 8.0.1xx patches only
Dead Ends
Common approaches that don't work:
-
Downgrading the target framework in .csproj to match an older installed SDK
75% fail
Changes the application's target framework, potentially breaking API usage and removing access to newer features. Other developers and CI systems still need the correct SDK, so this only fixes the local machine
-
Deleting global.json to use whatever SDK is installed
65% fail
global.json exists to ensure consistent builds across environments; removing it causes different developers to build with different SDK versions, leading to subtle behavioral differences and 'works on my machine' problems