DEV Community

Swapnil Takalkar
Swapnil Takalkar

Posted on

How to upgrade your current .Net framework to latest version?

If you want to upgrade your .Net core framework from 3.1/6/7 to latest .Net framework 6/7/8 then there are two ways to upgrade .Net framework. One way is manual and the other way is automatic by using Upgrade Assistant.

So, manual fix is that double click on the project to open .csproj file and then change the to version you wish to upgrade to.

Image description

Do so for each project and rebuild the entire solution. If build is successful, then you are almost done. Make sure that dotnet clean, dotnet build, dotnet test, dotnet pack and dotnet publish is working as expected. If some project fails due to package incompatibility, make sure you upgrade packages as well to compatible version.

You may also need to change your build pipeline to relevant MSBuild version and make sure that correct .Net runtime version is installed in all the environments of the project.

However, Microsoft has developed .NET Upgrade Assistant. Using it to upgrade .Net framework is recommended as it will check each file along with compatibility of packages developed by Microsoft. We have to use Upgrade Assistant project by project to upgrade automatically.

Let’s see how to do it step by step.

1) Download .NET Upgrade Assistant in Visual Studio. Extensions -> Manage Extensions

Image description

2) Search .NET Upgrade Assistant and click on download

Image description

3) You will see the message 'Your changes will be scheduled...' at the bottom.

Image description

4) Close Visual Studio. VSIX installer will start installing extension, as soon as you close Visual Studio.

Image description

Image description

Image description

5) Now open Visual Studio again.

6) In Solution Explorer, right click on your first project. Select Upgrade option.

Image description

7) Upgrade Assistant will open. Click on In-place project upgrade.

Image description

8) Select .Net framework you would like to migrate to and click Next.

Image description

9) If selected SDK is not present on your machine then you may see following window. You can click on the link given in the message which will take you to download page. Download and install relevant version of the SDK. After that, you may need to restart Visual Studio and open Upgrade Assistant again.

If you already have SDK on your machine go to next step.

10) You should see the screen like below. Click on Upgrade selection.

Image description

11) Upgradation will be started.

Image description

Image description

12) Upon completion you should see screen as of below:

Image description

13) Do the same process for each projects.

Image description

Once you are done with each project, rebuild entire solution. Do not forget to test solution using following commands: dotnet clean, dotnet build, dotnet test, dotnet pack and dotnet publish.

You can modify the build pipeline to build solution using relevant MSBuild version and install correct .Net runtime version in all the environments of the project.

Conclusion:
Efficient way to upgrade .Net framework is using .NET Upgrade Assistant. It is easiest way and it takes care of dependencies such as Microsoft packages.

Top comments (0)