Work on a lower version of dotnet core

Using a lower version of dotnet core in a PC has many dotnet core versions installed


At the time of writing this tutorial latest available .NET Core version is 6, while Visual Studio 2022 community is the latest available version of the Visual Studio family. But I wanted to modify and test an older application build using ASP.NET Core 2.2 and Visual Studio 2017. 

here are the versions available on my computer:


Show the current version and more information about installed SDKs



The current version is 6.0.0. But we want to create a project for the older version 2.2.

 globaljson  is help on working on older dotnet core

My working directory is  D:\dev\dotcli. We need to switch to the older version. To do that we need to add the global.json  file to the working root folder by using  the command globaljson

PS D:\dev\dotcli> dotnet new globaljson --sdk-version 2.2.108 --force

The globaljson command creates a global.json file


Check the current version again

PS D:\dev\dotcli> dotnet --version

It shows 2.2.108

Check the available commands in this version.

PS D:\dev\dotcli> dotnet new --help




Here in this example, I used a new folder. But if we need to work on an older project we just need to add this file to the root folder.

It is a simple solution.

Reference: global.json overview


Comments

Popular posts from this blog

Examining the Project structure - ASP.NET Core 7 Part 4

Getting Familiar with Visual Studio 2022 IDE - ASP.NET Core 7 Part 3

Displaying A Start Page In ASP.NET Core 3.1 Web API Project.