NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.1
Asked Answered
R

8

26
dotnet --list-sdks 

indicates that I have .net8.0.1 installed.

versions

My c# Solution has .Net7 and .Net8 projects and builds OK.

If I change the main project to have

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net8.0.101-windows</TargetFramework>
  

When I build I get

NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.1. Either target .NET 8.0 or lower, or use a version of the .NET SDK that supports .NET 8.0.1. Download the .NET SDK from https://aka.ms/dotnet/download

[Update] This is what I see in my bin\debug folder enter image description here

I deleted the obj and build folders. Now when I attempt to build I get NetSDK1004

I am using VS17.8.5

Redmon answered 15/1 at 4:3 Comment(1)
I believe you are supposed to write net8.0-windows without the minor versionsNejd
R
3

I reinstalled the latest sdk which was v8.0.101 cleaned rebuilt Now I only have the bin\debug\net8.0-windows folder as desired.

Redmon answered 22/1 at 6:32 Comment(1)
did the same but it had to be 32-bit. I thought everything was 64-bit but it seems notFaithfaithful
R
33

In my case, on visual studio for MAC 17.6.8, I had to select the following option:

Visual Studio => Preferences => Others => Preview Features => Use .NET 8 SDK if installed

Even though the version of .net8 I installed was not a preview version, I still had to select this option

Ragg answered 9/2 at 10:20 Comment(0)
P
19

If you use Visual Studio 2022 you have to upgrade to version 17.8+. More info here.

Preterit answered 16/3 at 10:32 Comment(1)
I have 17.8.6 and that error still shows (after attempt to upgrade project net6 -> net8). The solution is actually (or as well) to update or remove your global.json. See other answers: https://mcmap.net/q/514635/-netsdk1045-the-current-net-sdk-does-not-support-targeting-net-8-0-1Jacoby
D
5

I was getting the error as in below when I was changing the TargetFramework from net6 to net8.

Error   NETSDK1045  The current .NET SDK does not support targeting .NET 8.0.  Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 8.0.    Woodstock   C:\Program Files\dotnet\sdk\6.0.321\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets

The good thing is that there is a link to a post that explain everything about the error NETSDK1045. The link to the post is here. As explained there, This error occurs when the build tools can't find the version of the .NET SDK that's needed to build a project. This is typically due to a .NET SDK installation or configuration issue

The issue I was facing was related to the configuration in the global.json file. So I did dotnet --list-sdks to see the installed versions. And update the version.

  "sdk": {
  "version": "8.0.201"
  }
Disarming answered 20/2 at 10:20 Comment(1)
This was the solution for me when nothing else worked. Found and updated a global.json file in the root of the repo. Thanks!Donothing
O
5

Make sure you don't have the framework version defined in a global.json where your solution file is. Something like:

{
  "sdk": {
    "version": "6.0.201",
    "rollForward": "latestMinor",
    "allowPrerelease": false
  }
}
Onstad answered 27/6 at 13:11 Comment(0)
R
3

I reinstalled the latest sdk which was v8.0.101 cleaned rebuilt Now I only have the bin\debug\net8.0-windows folder as desired.

Redmon answered 22/1 at 6:32 Comment(1)
did the same but it had to be 32-bit. I thought everything was 64-bit but it seems notFaithfaithful
B
1

When looking at https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-8.0.101-windows-x64-installer it says that it is only supported for version of VS2022 (v17.8), for other versions of VS you can find the SDK available on this link

Or check the Directory.build.props, it is an optional file that can override your desired settings.

Broddie answered 19/1 at 13:22 Comment(0)
E
0

I encountered the ssue when working on a .NET application where I received the following error:

NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either 
target .NET 6.0 or lower, or use a version of the .NET SDK that supports 
.NET 8.0.

I discovered that the root cause was a global.json file in a parent directory specifying an SDK version that was no longer installed on my machine. This global.json file was inadvertently affecting my project, which was located in parent folder higher up from where my application resided.

So, check the parent folders to be sure there isn't a global.json file or at the very least ensure the framework specified is supported

Eldwin answered 15/7 at 13:21 Comment(0)
D
-1

Install the SDK and update the visual studio 2022.

Dobb answered 31/7 at 14:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.