Loading Old Projects In VS2017 After Installing VS2019

If you’re like me and come back to old projects and find that the project doesn’t load or that you get other errors like “The current .NET SDK does not support targeting .NET Core x.x…..”

Set the SDK in global.json

Look at the TargetFramework of the project. i.e.

<TargetFramework>netcoreapp2.2</TargetFramework>

Then check which versions are installed, open a command prompt and run

dotnet --list-sdks

Set_SDK

choose the closest match and then in the solution root folder create the global.json by running

dotnet new globaljson --sdk-version 2.2.100

References:

https://docs.microsoft.com/en-us/dotnet/core/tools/global-json?tabs=netcore2x#matching-rules

https://docs.microsoft.com/en-us/dotnet/core/install/how-to-detect-installed-versions?pivots=os-windows#check-sdk-versions