用visual studio创建的所有.net core解决方案不能添加工程, 解决:the project file cannot be opened by the project system

如图,我用visual studio创建的所有.net core解决方案都不能添加项目,而用framework则可以正常使用?

1.这个是.net core项目

用visual studio创建的所有.net core解决方案不能添加工程, 解决:the project file cannot be opened by the project system

2.这个是.net framework项目

用visual studio创建的所有.net core解决方案不能添加工程, 解决:the project file cannot be opened by the project system

我觉得可能是前几日因为误操作而删除了一部分系统环境变量导致的,经过测试后确实是这个原因。

解决方案:

右击我的电脑->属性->高级系统设置->高级->环境变量->系统变量
在path变量中添加 C:\Program Files\dotnet\ 然后重启visual studio

注意:不要改变原来的值,只要在后面添加,用分号分割。

然后就可以正常使用了,如图。
用visual studio创建的所有.net core解决方案不能添加工程, 解决:the project file cannot be opened by the project system