How to upgrade your current .Net framework to latest version?
Tags: dotnet, dotnetcore, dotnetframework
Published: 2023-10-11 15:35:58

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 <TargetFramework> to version you wish to upgrade to.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wqgwyvybwb8fgdv749br.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zfvvz81ewumeiprchode.png)

2) Search .NET Upgrade Assistant and click on download

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q1uc8vmvemqtw6x9n1wr.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x1yiia2g5gm2pvkfs8vv.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfil69hmq9wzo7vsweja.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grpjfa0ecipxndebesxi.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5yhy50qaaydu30rk8pum.png)



5) Now open Visual Studio again.

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9eiaspvi7sc07p0lsxt8.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pzz5hkpxlqh7t3igo8u.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chtbi8nr2zlnsuer7ca1.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iryxehd3rkeufm44jhgm.png)

11) Upgradation will be started. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a5chmhdyq4fhe6g1ljtj.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pf5ejro6ls0ed2sztiem.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4cclawlox1lkv8uv7d8.png)


13) Do the same process for each projects.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x71xr5fiuef37qchq46b.png)

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.