Solutions to "The solution shows 0 projects", "The .NET Core SDK cannot be located.", "The .NET Core SDK cannot be located" in VS

After Visual Studio 2019 creates a .NET Core console application, the number of "Solution" projects in it is displayed as 0, as shown in the figure below:
insert image description here
Try to import the .csproj file through "File - Add - Existing Project" to solve the problem

insert image description here
As a result, an error is reported: "The .NET Core SDK cannot be located." "The .NET Core SDK cannot be found"

The solution is as follows:

  1. Find the SDK version of dotnet under the file C:\Program Files\dotnet\sdk, as shown in the figure

C:\Program Files\dotnet\sdk

insert image description here


2. Knowing that the native SDK version is 3.1.301, create a global.json file in the root directory of the project file.
insert image description here


3. Write the following code in the global.json file, where version is the native SDK version number:

{
    
    
  "sdk": {
    
    
    "version": "3.1.301",
    "rollForward": "latestFeature",
    "allowPrerelease": false
  }
}

4. At this time, import the .csproj file again through "File - Add - Existing Project", the SDK will no longer report an error, and the number of projects in the "Solution" has also returned to normal

insert image description here

insert image description here


The above methods are successfully solved on this machine: "The solution shows 0 projects", "The .NET Core SDK cannot be located.", "The .NET Core SDK cannot be found" problems

Guess you like

Origin blog.csdn.net/weixin_43401024/article/details/129604277