.NET Version Management

.NET Version Management

·

2 min read

Download SDKs

Download the latest .NET SDK from its official site and install it. Now, verify the installation with the command:

dotnet --list-sdks

Visual Studio Installer

To start creating new projects with the latest .NET, update the visual studio itself with Visual Studio Installer (Search in Start Menu).

After updating from Visual Studio Installer, open Visual Studio and create new project. Now, guess what? You’ll see the latest .NET version in the option!

Congratulation! You have successfully updated the .NET version. But wait! What about the old projects?

The old projects are still using the older .NET version. To update that, simply update the TargetFramework property in .csproj file of the project. Here is how you update older project from .NET 8 to .NET 9.

You can also update the older packages from Tools > Nuget Package Manager > Manage NuGet Packages for Solution. You are now ready to rock with the latest .NET version.

Downgrading to Old Version

Image a scenario where your project lead made you to downgrade the project version from latest to old. Later on told you to get back to the latest version again. Now, what would you do?

Don’t worry. It’s a piece of cake! You can switch the project version from latest to older by going to the project directory and running the following command:

dotnet new globaljson --sdk-version 8.0.101

In the above example we’re downgrading from 9.0.102 to 8.0.101. This command will create a global.json file on the project directory. Rebuild the project and you’re ready to work with your legacy project!

💡
Here also, do not forget to change the TargetFramework property in .csproj file of the project, everytime you switch between .NET versions.

You can again switch the project version from older to latest version by adding —force argument on the above command. Since, the global.json file was already created, it needs to be overridden to switch again:

dotnet new globaljson --sdk-version 9.0.102 --force

Now, rebuild the project and grab yourself some coffee. You deserve it!