Skip to content

Error: NETSDK1045

Shelvin Datt edited this page Mar 26, 2025 · 1 revision

Error: NETSDK1045 - ".NET SDK does not support targeting .NET 8.0"

Problem:

You are encountering the following build error:

Severity Code Description Project File Line Suppression State Error NETSDK1045 The current .NET SDK does not support targeting .NET 8.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. BlueCorpDispatchAuto C:\Program Files\dotnet\sdk\5.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets 141

Cause:

This error indicates that your project is configured to use .NET 8.0, but the .NET SDK version installed on your system is incompatible. Specifically, the error message points to the SDK version 5.0.401, which does not support .NET 8.0.

The most likely reason for this mismatch is that you are attempting to build the solution using Visual Studio 2019.

Explanation:

  • Visual Studio 2019 was released before .NET 8.0 and does not include the necessary .NET SDK components to support it.
  • .NET 8.0 requires a more recent version of the .NET SDK, which is typically bundled with Visual Studio 2022 or installed separately.

Solution:

  1. Upgrade to Visual Studio 2022: The recommended solution is to install and use Visual Studio 2022. This version comes with the .NET 8.0 SDK and the necessary tools to build and run .NET 8.0 applications.

  2. Install .NET 8.0 SDK Separately (Less Recommended): If upgrading Visual Studio is not immediately feasible, you can try installing the .NET 8.0 SDK separately from the Microsoft website. However, this may lead to compatibility issues if Visual Studio 2019 lacks other required components.

  3. Retarget the Project to .NET 5.0 (If Possible): If you don't specifically require .NET 8.0 features, you can retarget your project to .NET 5.0, which is supported by the installed SDK. However, this may involve code changes and limit you to the features available in .NET 5.0.

In summary, the NETSDK1045 error when targeting .NET 8.0 with SDK 5.0.401 is primarily due to using Visual Studio 2019. The recommended solution is to upgrade to Visual Studio 2022 to ensure compatibility with .NET 8.0.

Clone this wiki locally