[BUG] Nuget restore encountered two errors "Failed to load msbuild Toolset" and "The current .NET SDK does not support setting .NET 6.0 as the target"

Error environment:

Visual Studio 2019

1. Failed to load msbuild Toolset

insert image description here
Solution: https://github.com/NuGet/Home/issues/4091 , install MSBuild, or use nuget update -selfan update, the new version of NuGet has solved this problem.

2. The current .NET SDK does not support targeting .NET 6.0

If you only install .NET 6.0, you will find that it still doesn’t work, because nuget will find the SDK in vs 2019 by default. So the next vs2022 will be fine!

1. Install NET 6.0

Note: Now (June 3, 2022) there is already NET 7.0 preview, but there is no stable, and NET 7.0 can also be installed.

Click Download: Download .NET 6.0 (Linux, macOS, and Windows) .

2. Install the latest version of Visual Studio

Note: The latest version is VS 2022.

Click to enter the installation tutorial on the official website: Install Visual Studio .

3. Update nuget

Run the following command:

nuget update -self

Note: If the above command prompts that nuget is not installed, please install it first.
Click to enter the NuGet download page: Available NuGet Distribution Versions .

Guess you like

Origin blog.csdn.net/qq_46106285/article/details/125108107