安裝 VS 2022以後,舊版VS2019 出現 .NET Core 5 / .NET Standard 2專案無法載入。
錯誤訊息 — The project file cannot be opened. Unable to locate the .NET SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
As all .NET developers I am quite excited by Visual Studio 2022 and .NET 6 going RTM. However I noticed that Visual Studio 2022 RTM install messed up Visual Studio 2019. Our .NET 5 and .NET Standard 2 projects couldn’t be loaded anymore in Visual Studio 2019. The error shown when attempting to load the projects was:
The project file cannot be opened. Unable to locate the .NET SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version.
Visual Studio 2022 put C:\Program Files (x86)\dotnet\ before C:\Program Files\dotnet\. Just restore the right order et voilà 🙂
第一,滑鼠點選「本機」,按下 滑鼠右鍵
第二,選擇 “進階系統設定” ,然後修改 “環境變數 (PATH) “
下圖第四點 (4) 的順序很重要!!
資料來源
相關影片