The Problem
When trying to build or run a .NET project, you encounter the following build error in your terminal or Visual Studio Output window:
error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target a .NET SDK version that supports .NET 8.0, or use a .NET SDK version that supports the current target.
This happens because the MSBuild engine or the .NET CLI is attempting to compile code for a specific framework version (in this case, .NET 8.0) but cannot find a compatible SDK installed on your Windows machine, or it is being forced to use an older SDK version by a configuration file.
TL;DR: Quick Solutions
- Install the SDK: Download and install the specific .NET SDK version from the official Microsoft download page.
- Update Visual Studio: If you are using Visual Studio, open the Visual Studio Installer and update to the latest version. .NET 8.0 requires at least Visual Studio 2022 (v17.8 or newer).
- Check global.json: Look for a
global.jsonfile in your project or parent folders. If it specifies an older version, the build will fail even if you have the new SDK installed.
Detailed Root Causes
1. Missing SDK Version
The most common cause is simply not having the .NET 8.0 SDK installed. Windows doesn't always automatically update .NET SDKs through Windows Update; they often require manual installation or a Visual Studio update.
2. Visual Studio Version Mismatch
Visual Studio and the .NET SDK are tightly coupled. If you are trying to use .NET 8.0 but are running Visual Studio 2019 or an older version of Visual Studio 2022, the internal MSBuild version won't know how to handle the .NET 8.0 project structure.
3. Restriction via global.json
The global.json file is used to lock a project to a specific .NET SDK version. If a teammate created this file specifying .NET 6.0, and you updated the project to target .NET 8.0, the CLI will still try to use the 6.0 SDK and throw NETSDK1045.
4. Architecture Mismatch (x86 vs x64)
On 64-bit Windows, you might have the x86 version of the SDK installed but the project is looking for the x64 version, or your PATH environment variable is pointing to C:\Program Files (x86)\dotnet\ instead of C:\Program Files\dotnet\.
Step-by-Step Fixes
Approach 1: Verify and Install the Correct SDK
First, check what versions are actually visible to your system. Open PowerShell or Command Prompt and run:
dotnet --list-sdks
If you don't see 8.0.xxx in the list, you must install it. Go to the .NET 8.0 Download Page and grab the SDK x64 installer for Windows. Restart your terminal after installation.
Approach 2: Update Visual Studio 2022
.NET 8.0 support was introduced in Visual Studio 2022 version 17.8. If you are on 17.7 or lower, you will see NETSDK1045.
- Open the Visual Studio Installer.
- Click Update on your Visual Studio 2022 instance.
- Once updated, ensure the ".NET desktop development" workload is checked and that ".NET 8.0 Runtime" is selected in the individual components tab.
Approach 3: Fixing global.json
Search your project root directory for a file named global.json. It usually looks like this:
{
"sdk": {
"version": "6.0.100"
}
}
If this file exists, it overrides everything else. You have two choices:
- Delete it: This allows the system to use the latest installed SDK.
- Update it: Change the version string to match your installed .NET 8.0 SDK (e.g.,
"8.0.100").
You can find your exact version string by running dotnet --version.
Approach 4: Checking Environment Variables
If dotnet --list-sdks shows the version you need but the build still fails, your PATH might be messed up. Windows sometimes prioritizes the 32-bit (x86) dotnet path over the 64-bit one.
- Search for "Edit the system environment variables" in the Start menu.
- Click Environment Variables.
- Under System variables, find Path and click Edit.
- Ensure
C:\Program Files\dotnet\is aboveC:\Program Files (x86)\dotnet\.
Verification: How to confirm the fix
After performing the steps above, run the following commands in your project directory:
# Check the active version
dotnet --version
# Try to build the project
dotnet build
If the build succeeds without the NETSDK1045 error, your environment is correctly configured. If you are using Visual Studio, try cleaning the solution (Build > Clean Solution) and restarting Visual Studio to ensure it picks up the new SDK paths.

