Tools to Upgrade Your Existing .Net App to .NET Core/.NET 6.0

05 Jan 2024
Intermediate
64.9K Views
11 min read  

Tools to Upgrade Your Existing .Net App to .NET Core/.NET 6.0: An Overview

.NET 6 is one of the Long-Term support-based versions provided by Microsoft. Except for the cross-platform environment, .NET Core also provides better performance along with several enhancements over the earlier .NET Framework. Also, it is an Open source-based framework and not proprietary, as a Framework used to be. So, if an application is developed using the earlier version of the .NET like. .NET 4.5 or 4.8 or .NET Core 1.0, etc., we can migrate or upgrade the application to the latest .NET version i.e., .NET 6.0.

To make things easier for you, Dot Net Tricks brings a comprehensive skill-oriented ASP.NET Core Certification to the nitty-gritty of ASP.NET.

Migrate into .Net Core 6 from Earlier .Net Core Version

In this section, we will discuss related to the migration process for any existing application which is developed in the earlier version of ASP.NET Core like 3.1 or 5.0. To upgrade any applications to the latest .NET Core version, we need to install Visual Studio 2022 with Asp.Net and Web Development workload. It is the only prerequisite related to this upgrade process. During the upgrade process, we need to follow the below instructions or steps –

  • If in our process we use a global.json file, then we need to upgrade the target .NET SDK Version.
  • 
    {
     "sdk": {
     "version": "6.0.100"
     }
    }
    
  • We need to update the Project File’s Target Framework to .net6.0
  • 
    <Project Sdk="Microsoft.NET.Sdk.Web">
     <PropertyGroup>
     <TargetFramework>net6.0</TargetFramework>
     </PropertyGroup>
    </Project>
    
  • In the structure of the project, we need to update the Nuget Packages which we used. In the Nuget Package part, we need to update each Microsoft.AspNetCore.* and Microsoft.Extensions.* package reference version to 6.0.0 or higher (as per the availability).
  • 
    <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="6.0.0" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0" />
     <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
     <PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
    </ItemGroup>
    

    After the update of the package, we need to delete the bin and obj folders. Also, we can run the command dotnet nuget locals –clear all to clear the Nuget package-related cache.

  • .NET 6 fully supports the existing startup.cs class and Hosting model of the earlier .Net Core versions.

Migration Tools to Upgrade Application to .Net 6/.Net Core 6

So, in this section, we will discuss the process of migrating or porting our code from the .NET Framework to the latest .NET 6.0. For any simple application-based project, the porting process from the earlier .NET framework to the current .NET 6.0 is much more straightforward. However, as per the complexity level of the projects, we may need to work extra after the initial migration of the project files to the latest version.

If the application already uses the app model using .NET (such as libraries, consoles, or desktop-based applications), then we usually require very little change. But if the application requires a new app model like an application using Asp.Net and we want to migrate it into Asp.Net Core, then we require more work.

For this type of scenario, instead of manually porting an application into .NET 6, we can use different tools that help us automate some aspects of work during the migration. Because porting a complex solution is always a complex process. These types of tools will help us in that process. There are several tools available for porting applications. Some of the tools are -

  1. .NET Upgrade Assistant
  2. .NET Portability Analyzer
  3. Try-Convert Tool

1. .NET Upgrade Assistant

The .NET Upgrade Assistant is a command-line tool that can be used for different kinds of .NET applications. This tool is mainly developed to assist in the upgrading process of any application from .NET Framework to .NET 6. After running the tool, the application always requires some additional effort to complete the migration. This tool contains the installation process of analyzers which can provide help to us while completing the migration process.

Now, this tool supports the following .NET Framework-based application types –

  • .NET Framework Windows Forms apps
  • .NET Framework WPF apps
  • .NET Framework ASP.NET MVC apps
  • .NET Framework console apps
  • .NET Framework class libraries

This tool mainly uses MSBuild to work with the project files. So, to work perfectly with this tool, it is necessary to install the latest version of MSBuild. For this purpose, we can install the latest version of Visual Studio. This tool needs to be installed with the help of the .NET CLI tool. We need to run the below commands to install the tools –


dotnet tool install -g upgrade-assistant

Evolution of ASP.NET Core

If you have already installed the .NET Upgrade Assistant tools, then you can upgrade the version by using the below commands –


dotnet tool update -g upgrade-assistant

Evolution of ASP.NET Core

Now, after the installation of the tools, we need to run the tools for our existing application project to upgrade to .NET 6.0 framework. So open the terminal and navigate to the folder where the target project or solution is located. Then run the below commands to upgrade the framework version –


upgrade-assistant upgrade.

The tool runs and shows you a list of the steps it will do and perform the upgrade process.

2. .NET Portability Analyzer

The .NET Portability Analyzer is a tool through which can analyze our existing projects and prepare detailed reports based on targeting .NET Framework to which components or parts are missing in the applications or libraries. The .NET Portability Analyzer is provided as a Visual Studio Extension and it can analyze one assembly per project.

To start work using the .NET Portability Analyzer in Visual Studio, we first need to download and install the extension from theVisual Studio Marketplace. Currently, it supports either Visual Studio 2017 or Visual Studio 2019. After installation, we need to configure it in Visual Studio through Analyze >Portability Analyzer Settings and select our Target Platforms, which are the .NET platforms/versions that you want to evaluate the portability gaps compared with the platform/version that your current assembly is built with.

3. Try-Convert Tool

The try-convert tool is a .NET global tool that can convert a project or entire solution to the .NET SDK, including moving desktop apps to .NET 6. However, this tool isn't recommended if your project has a complicated build process such as custom tasks, targets, or imports. This is a simple tool that will help in migrating .NET Framework projects to .NET Core.

Install it as a global tool here: dotnet tool install -g try-convert

If you have already installed it, make sure to update: dotnet tool update -g try-convert

Now, to use this tool simply navigate to the root of your solution by using a normal command prompt and simply execute:

try-convert

If you only want to convert a specific subfolder, solution, or project, type: try-convert -w path-to-folder-or-solution-or-project

Summary

By taking ASP.NET Core Training Online from Dot Net Tricks, you will understand that Asp.net Core 6.0 has been released with many new features and functionality. In this article, we discuss the different migration processes of the. Net-based application from an earlier version to the latest .NET 6.

FAQs

Q1. What are the various tools for porting an application into .NET 6?

  1. .NET Upgrade Assistant
  2. .NET Portability Analyzer
  3. Try-Convert Tool

Q2. What are the .NET Framework-based application types supported by .NET Upgrade Assistant?

  • .NET Framework Windows Forms apps
  • .NET Framework WPF apps
  • .NET Framework ASP.NET MVC apps
  • .NET Framework console apps
  • .NET Framework class libraries

Q3. What's the use of .NET Portability Analyzer?

The .NET Portability Analyzer is a tool through which can analyze our existing projects and prepare detailed reports based on targeting .NET Framework to which components or parts are missing in the applications or libraries.
Share Article
About Author
Debasis Saha (Technical Manager, Author and Mentor)

He is an ASP.Net, MVC and Angular Technical Manager with 10 years of experience. He always been a great fan of Microsoft Technologies and loves working on them. He has expertise in Asp.Net, MVC, SQL Server, MongoDB, Angular JS, and Angular. He loves to write articles about these technologies.
Learn to Crack Your Technical Interview

Accept cookies & close this