VS2019打开.NET Core 的项目,无法加载,显示如下错误信息:

"error : The project file cannot be opened by the project system, because it is missing some critical imports or the referenced SDK cannot be found.
Detailed Information: Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version."

根据错误提示,好像是找不到.NET Core SDK,于是打开Power Shell,输入 dotnet 命令,却找不到,我暗自高兴。

解决办法1

于是重新下载了最新版的.NET Core SDK,安装的时候提示修复或卸载:

The project file cannot be opened by the project system, because it is missing some critical imports or the referenced SDK cannot be found 的解决办法-程序旅途

我选择了“修复”。结束后重新打开解决方案,还是无法加载。

我又重试了“卸载”,然后重新安装,再次打开可以了。

也没明白为什么出现这种情况,大概是前两天执行了VS2019的一个更新

The project file cannot be opened by the project system, because it is missing some critical imports or the referenced SDK cannot be found 的解决办法-程序旅途

或者是安装了.NET桌面开发的缘故

The project file cannot be opened by the project system, because it is missing some critical imports or the referenced SDK cannot be found 的解决办法-程序旅途

解决办法2

出现这个问题其实是环境变量的问题,只需要在系统变量的Path里添加上

C:\Program Files\dotnet\

如下图所示

The project file cannot be opened by the project system, because it is missing some critical imports or the referenced SDK cannot be found 的解决办法-程序旅途

当然,我依然不清楚为什么没有了。