Skip to content

NETSDK1045: Resolving ".NET SDK does not support targeting .NET 8.0" Errors

Problem Statement

The NETSDK1045 error occurs when your .NET project targets a runtime version (e.g., net8.0.101-windows) not recognized by your currently active .NET SDK. This manifests as:

NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.1. Either target a lower version or update the SDK.

Common triggers include:

  • Incorrect SDK version in global.json
  • Visual Studio using an outdated version behind the scenes
  • Project targeting a .NET version not installed or unsupported by your IDE
  • Typos in the <TargetFramework> (e.g., net8.0.101-windows instead of net8.0-windows)

Solutions

1. Verify and Correct global.json

The global.json pins your SDK version, which may mismatch your project's needs.

  • Locate global.json:
    Check your solution directory and parent folders. Delete or modify it if outdated.
  • Check installed SDKs:
bash
dotnet --list-sdks  
# Output example: 8.0.301 [C:\Program Files\dotnet\sdk]
  • Update global.json to match an installed SDK:
json
{  
  "sdk": {  
    "version": "8.0.301",    // Match your installed version  
    "rollForward": "latestFeature"  
  }  
}

Or remove global.json entirely if pinning isn’t needed.

WARNING

global.json can exist in parent directories and override SDK versions unexpectedly.

2. Update Visual Studio and .NET SDK

Ensure Visual Studio 2022 v17.8 or later for .NET 8 support:

  • Go to Tools > Check for Updates.
  • For .NET 9+ projects, use Visual Studio 2022 17.12+.

If using Visual Studio for Mac:

Navigate to Visual Studio > Preferences > Preview Features > Use .NET 8 SDK if installed.

3. Install the Correct SDK Version

  1. Visit the .NET SDK Download Page.
  2. Select the exact version matching your <TargetFramework>.
  3. Restart Visual Studio after installation.

4. Validate <TargetFramework> Syntax

Incorrect:

xml
<TargetFramework>net8.0.101-windows</TargetFramework>

Correct (platform-agnostic):

xml
<TargetFramework>net8.0</TargetFramework>

Correct (Windows-specific):

xml
<TargetFramework>net8.0-windows</TargetFramework>

5. Clean Project and Reload

  1. Delete bin and obj folders:
bash
rmdir /s/q bin obj  
# Or PowerShell: Remove-Item -Recurse -Force bin, obj
  1. Reload the project in Visual Studio.

6. Verify Environment Variables

Accidental overrides (like MSBuildSDKsPath) cause conflicts:

  • In Windows search, type "Environment Variables."
  • Remove any variables manually setting SDK paths unless specifically required.

Key Notes

  • Target .NET versions using logical names (net8.0), not build numbers.
  • Unbind SDK version pins unless strictly necessary.
  • Use Visual Studio 2022+ for .NET 8/9 projects; close Visual Studio 2019.
  • The .NET CLI (dotnet build) may behave differently than Visual Studio due to hidden SDK paths.

Conclusion

Resolve NETSDK1045 by syncing SDK versions with the global.json file, updating IDE/SDK installations, and ensuring correct target framework syntax. Most conflicts stem from implicit version pins via global.json or IDE-SDK misalignment. Regular updates and validating SDK installations (dotnet --list-sdks) prevent recurring issues.

TIP

Run dotnet --info to see active SDKs, runtimes, and environment details when debugging mismatches.