Araf Hasan
Araf Hasan

Reputation: 31

Visual Studio 2019 shows an empty solution after creating a .NET Core project

When I create a new .NET Core project in Visual Studio 2019, it shows only the solution file. Other files are not showing and also I am not able to debug or the project.

An empty solution node shown in Solution Explorer in Visual Studio 2019

Upvotes: 3

Views: 4914

Answers (2)

Tibi
Tibi

Reputation: 3875

I have encountered this issue in newer versions of Visual Studio as well with .NET 5 and .NET 6. There is a bug where Visual Studio can't find the installed SDK. Here is my suggested fix:

  1. Go to Settings/Apps and Features and check the bitness of your installed .NET SDK.

  2. Edit the PATH environment variable, and make sure the path to dotnet that matches the bitness of your installed SDK is set before the other one (or remove the other one completely):

    • for a 32-bit SDK: C:\Program Files (x86)\dotnet\
    • for a 64-bit SDK: C:\Program Files\dotnet\
  3. Restart Visual Studio (if you are using some kind of launcher, restart that launcher as well, since environment variables are inherited).

You can test if this works correctly by opening a command prompt and typing:

dotnet --list-sdks

The list should not be empty.

Upvotes: 0

Gary
Gary

Reputation: 51

I've also run into this problem and after two days of searching forums and reading .NET documentations, I finally managed to find the solution.

The problem is that Visual Studio cannot find the proper SDK version. There might be a few reasons for this, but first of all, check if you have any SDK installed:

  1. Open the Command Prompt:

    Start Menu > Visual Studio 2019 > Developer Command Prompt for Visual Studio 2019

  2. Run the command: dotnet --info

Case 1:

The .NET SDKs installed: section says that you have no SDKs installed.

-OR-

A .NET SDK is installed but not for the right architecture (this was my case), meaning that you had installed x86 version instead of x64.

Solution: Uninstall all versions of .NET Core SDKs and Runtimes, then download and install the latest x64 SDK and Runtime version from Microsoft's webpage.

Case 2:

A .NET SDK is installed but the referenced SDK version in the current project's .csproj file does not match the installed version nor the one specified in the global.json (if exists).

Solution: Edit the .csproj file, so that the SDK versions match. If you have or need a global.json file, make sure you set its content properly. You can read more about it here.

Finally

Don't forget to open Visual Studio, create a new e.g. Console Application and see if the Solution's files appear in the Solution Explorer window (they should). Note that existing projects may still not be working properly because their .csproj file might have wrong SDK reference - if so, you have to fix them manually.

Upvotes: 3

Related Questions