Kirsten
Kirsten

Reputation: 18160

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

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

Upvotes: 40

Views: 82581

Answers (12)

vlijia stefan
vlijia stefan

Reputation: 21

.Net 9.0 is supported starting with Visual Studio 17.12

https://dotnet.microsoft.com/en-us/download/dotnet/9.0

Upvotes: 2

jwezorek
jwezorek

Reputation: 9545

FYI the dumb mistake that may have led to many people reading this StackOverflow question is accidentally launching Visual Studio 2019 when you meant to launch Visual Studio 2022.

Upvotes: 4

Frane Krapić
Frane Krapić

Reputation: 29

I had the same error, but with .NET8 and .NET9. Fixed it by installing Visual Studio Preview.

Upvotes: 1

NoWar
NoWar

Reputation: 37632

I have got the same issue. So I was not able to open some of the projects in Visual Studio 2019.

What I did is following.

  1. Go here https://dotnet.microsoft.com/en-us/download/dotnet
  2. Define the the SDK you have by error. For example in my case it was SDK 8.0.303
  3. Navigate in it and in the the left top corner you will see the SDK you need. For example in my case it was the page https://dotnet.microsoft.com/en-us/download/dotnet/8.0
  4. Just download and install it.
  5. Restart your Visual Studio 2019.

enter image description here

Upvotes: 1

Dayan
Dayan

Reputation: 375

Install the SDK and update the visual studio 2022.

Upvotes: -2

BDarley
BDarley

Reputation: 1275

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

Upvotes: 0

Sal
Sal

Reputation: 5694

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
  }
}

Upvotes: 13

DanielV
DanielV

Reputation: 2690

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

Upvotes: 42

Sibeesh Venu
Sibeesh Venu

Reputation: 21779

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"
  }

Upvotes: 7

Jonathan S.
Jonathan S.

Reputation: 471

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

Upvotes: 47

Kirsten
Kirsten

Reputation: 18160

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.

Upvotes: 3

Max
Max

Reputation: 862

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.

Upvotes: 1

Related Questions