vs2019 solves NETSDK1045 error
1. Platform description
System: Windows 10
VS: Visual Studio 2019
2. Problem description
When I downloaded the WPF sample code from Microsoft's official website and ran it, the problem occurred,
NETSDK1045 The current .NET SDK does not support targeting .NET 6.0. Please install .NET 5.0 or lower
3. The cause of the problem
This error occurs when the build tools cannot find the version of the .NET SDK required to build the project. This is usually due to a .NET SDK installation or configuration issue. A full error message resembles the following example:
- NETSDK1045: The current .NET SDK does not support targeting "newer version". Target an "older version" or lower, or use a .NET SDK version that supports a "newer version".
Four, the solution
Refer to the solution on the official website:
Reference link: https://docs.microsoft.com/zh-cn/dotnet/core/tools/sdk-errors
Because the global.json file is deleted, an error is still reported
So I used to install .net 6.0 SDK to solve the error problem
-
1. Go to the .NET download page (choose .net 6.0)
-
2. Select the latest version - Windows x86
[Download x86 or x64 as needed here, I just download to run the code, basically has nothing to do with the architecture, just choose one, and you can also choose x86 when running] [You can see
here .net is only supported by vs2022, not supported by vs 2019]
-
3. Just download the sdk and run it directly, it will be installed automatically without configuration
-
4. Restart VS2019, open the solution, and configure the project properties
[vs 2019 does not support .net 6.0, so I configured .net 5.0]
-
5. Run the example - success