.NetSDK – Build – Error – NETSDK1045 – “The current .NET SDK does not support targeting .NET Core 3.1. Either target .NET Core 3.0 or l ower, or use a version of the .NET SDK that supports .NET Core 3.1.”

Background

A day or two short of a week ago, a family member ran into issues building a Microsoft  .Net application that he had downloaded from GitHub.

Error

Error Message – NETSDK1045


Error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.1.

Either target .NET Core 3.0 or lower, or use a version of the .NET SDK that supports .NET Core 3.1.

TroubleShooting

Outline

  1. Project File
    • Review Project File

Project File ( .csproj )

Review Project File ( .csproj )

Text

<Project Sdk=”Microsoft.NET.Sdk”>
<PropertyGroup>
<TargetFrameworks>net452;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks Condition=”‘$(CoreOnly)’ == ‘True'”>netcoreapp3.1</TargetFrameworks>

Image

 

Explanation

  1. Targeted Framework
    • net452;netcoreapp3.1
      • .Net Standard:- net452
      • .Net Core:- netcoreapp3.1

.Net SDK

Objective

  1. List Installed SDK

List Installed SDK

dotnet

Syntax

dotnet --list-sdks

Sample

dotnet --list-sdks

Output
Output Text

C:\&gt;dotnet --list-sdks
1.1.8 [C:\Program Files\dotnet\sdk]
3.0.6 [C:\Program Files\dotnet\sdk]
5.0.400 [C:\Program Files\dotnet\sdk]

Guidance

Depending on the version of .Net Core we are targeting, one needs a minimum version of Visual Studio .NET.

.NET Core Version – Minimum Visual Studio Version

.Net Core Version Visual Studio Version
.NET Core 3.0 Visual Studio v16.3
.NET Core 3.1 Visual Studio v16.5
.NET Core 5.0 visual studio v16.6 latest preview
.NET Core 6.0 visual studio v17.0 latest preview

Decision Point

Our error message states that the solution/project we are trying to build is targeting “.NET Core 3.1“.

But, our current .Net SDK is only able to target .NET Core 3.0 or lower.

Either, we change our targeted version or upgrade our .Net SDK.

We chose to upgrade our .Net SDK.

 

Remediation

Outline

  1. Microsoft Visual Studio
    • Visual Studio Installer
      • Upgrade
    • Visual Studio
      • Upgrade

Microsoft Visual Studio

Visual Studio Installer

Objective

We have Microsoft Visual Studio Community 2019 installed.

Please check that you have the latest version of the installer installed.

If not, please upgrade the installer to the latest version.

Determination

Please explore the following options to determine whether you have the latest version of the installer:-

  1. Launch Visual Studio Installer
    • Please note whether you are offered an update for the installer itself

If updates are available for the installer itself, here is what will be shown:-

Upgrade Visual Studio Installer

Our current version of Visual Studio Installer is 16.3.10.

We are offered 16.11.2.

 

Images

Image – Visual Studio Installer – Visual Studio Community 2019
Image – Visual Studio Installer – Visual Studio Community 2019 – Update available

Image – Visual Studio Installer – Visual Studio Community 2019 – Downloading and verifying

Image – Visual Studio Installer – Visual Studio Community 2019 – Downloading and verifying

Image – Visual Studio Installer – Visual Studio Community 2019 – Installed

 

Microsoft Visual Studio

Visual Studio

Objective

Accessed Control Panel \ “Programs and Features”.

Noted the version of Visual Studio 2019 currently installed.

The version number is 16.3.29519.87.

Upgrade

We have v16.3 installed, but we need at least a version 16.5.

We thus upgraded our installed version of Visual Studio 2019.

 

Review – Post Upgrade

Please review the current version of Visual Studio.

MS Build

Launched Visual Studio 2019 Developer Tools.

MS Build – Version – Syntax

msbuild -version

MS Build – Version – Sample

msbuild -version

MS Build – Version – Output – Text

>msbuild -version
Microsoft (R) Build Engine version 16.11.0+0538acc04 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.11.0.36601
>

MS Build – Version – Explanation

We successfully upgraded Visual Studio 2019 Command Lines tool to version 16.11.0.36601.

dotnet
Syntax

dotnet --list-sdks

Sample

dotnet --list-sdks

Output Image
Output Text

C:\>dotnet --list-sdks
1.1.8 [C:\Program Files\dotnet\sdk]
3.1.412 [C:\Program Files\dotnet\sdk]
5.0.400 [C:\Program Files\dotnet\sdk]

Images

Image – Control Panel – Programs and Features
Image – Control Panel – Programs and Features – Visual Studio Community – Installed
Image – Visual Studio – Post Upgrade – Version

Crediting

Crediting Dominic Jonas:-

Stack Overflow
The current .NET SDK does not support targeting .NET Core 3.0 | 3.1 | 5.0 | 6.0
Link

 

Summary

Visual Studio

This was a hard hurdle to overcome.

Here are the steps we took:-

  1. Upgraded
    • Upgraded .Net Core Runtime
    • Upgraded .Net Standard Runtime

If not for Dominic Jonas, would not have known we needed to upgrade Visual Studio, as well.

After the fact, it makes sense.

But, never forget the person that makes it make sense.

.Net Core SDK

BTW, we likely could have looked to install/upgrade .Net Core SDK rather than Visual Studio.

If you will like to explore the .Net Core SDK Route, please use this link.

  1. Microsoft – Visual Studio – SDK
    Link

 

References

  1. Microsoft
    • Visual Studio
      • Microsoft – Visual Studio – SDK
        Link
    • Docs
      • Docs > .NET > .NET fundamentals
        • NETSDK1045: The current .NET SDK does not support ‘newer version’ as a target.
          Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s