Microsoft Visual Studio 2019: The project file cannot be opened. Unable to locate the .NET SDK
Try to edit envrionment Variables.
Right click on This PC -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables
Add [install path] C:\Program Files\dotnet\
to the variable path.
Restart visual studio.
If it does not solve this problem, you can refer to this answer.
I found that the path C:\Program Files\dotnet
was already in my path but it was ordered below the C:\Program Files (x86)\dotnet
entry. By simply moving C:\Program Files\dotnet
above C:\Program Files (x86)\dotnet
in the list and restarting Visual Studio cleared up the problem.