Modernize and Upgrade: Latest .NET Core Framework
Business Statement
Recently I was working as a cloud migration architect to migrate several on-premise applications to Microsoft Azure Cloud. During the portfolio analysis, we found that many of the on-premise applications were created long ago by using very initial versions of the Microsoft .NET Framework.
The frameworks in these applications were already at the end of their lifecycles and it would not be easy to get any support for those frameworks. These frameworks were also not supported on Azure Platform as Service (PaaS) offerings.
Options To Migrate Application to Cloud
Based on the 7 Rs strategy, there are many options available to move an existing application to the Cloud. The below diagram suggests a few of them for reference.
7 R strategies for cloud migration
We can see that following the “Rehosting” path for the existing application is the easiest choice to move the existing application to the Cloud, but it does have limitations. Rehosting (a.k.a “Lift and Shift”) is only supported by leveraging the IaaS (Azure VM) offering of the Cloud and this also limits the utilization of the PaaS offering of Microsoft Azure (Azure Web app, Containerization, Auto Scaling, etc.) as well as any future enhancement of the application. This also limits the use of any feature offered by the latest Microsoft .NET Core Framework.
( Above image is taken from the AWS blog and has been modified for Microsoft Azure. Any credit for the image is with the original publisher.)
What Is .NET Core?
.NET Core is a new version of the .NET Framework, which is a free, open-source, general-purpose development platform maintained by Microsoft. It is a cross-platform framework, so if your application needs to run on multiple platforms apart from windows, then .NET core is the go-to platform as it is compatible across Windows, Linux, and Mac operating systems.
How To Upgrade To .NET Core
Upgrading any Microsoft .NET Framework to .NET Core is a process. In the below diagram, we can see that this process involves four main steps:
- Starts from the analysis of the existing code
- Upgrading the project files to .NET Core files
- Fixing the issues related to coding
- Testing the application for target .NET Core version
Step 1: Analysis of Existing Code
This step involves the analysis of the existing code base to find the portability compatibility for the .NET Core Framework.
There are a few .NET technologies that are not available or compatible with .NET Core.
- Windows Specific APIs: If your application is designed to work with the Windows Registry or WMI, it won’t be possible with .NET Core since Core is considered to be isolated from the underlying OS.
- Language support: Even though VB and F# are said to be compatible with .NET Core, there are a few project types that do not support them.
- Workflow-related services: Workflow Services and Data Services are only available with .NET Framework.
- Web Forms: ASP.NET Web Forms are only available in the .NET Framework.
- Web Pages: ASP.NET web pages are left out from .NET Core.
.NET Portability Analyzer
Analysis of existing code is done through Microsoft .NETPortability Analyzer. This tool can be accessed from Visual Studio 2019. After installing it, you can configure the various analysis parameters and output format for the generated reports.
The tool will help to specify the target .NET Core Framework(s).
Portability Summary
Summary reports give the portability percentage for each assembly included in the analysis. In the below diagram, we can see that included assembly svcutil is 71.24% compatible with .NET Core + Platform Extensions.
Details
The Details section of the report lists the APIs missing from any of the selected Targeted Platforms.
Missing Assemblies
Any assemblies that are missed and not being analyzed will be presented in the missing assembly section.
Step 2: Upgrade the Code
In this step, you need to convert the existing project files, solution files and NuGet packages as the latest .NET Core Framework. Depending on the project size, this process can be time consuming process.
.NET Upgrade Assistant Tool
The .NET Upgrade Assistant is a command-line tool that can be run on different kinds of .NET Framework apps. This toll will help to upgrade .NET Framework apps to .NET 6. After running the tool, in most cases the app will require additional effort to complete the migration. The tool includes the installation of analyzers that can assist with completing the migration.
Step 3: Build the Code Using Visual Studio IDE
After the execution of .NET upgrade assistant tool, you will get a partially modified code for latest .NET Core Framework. You need to open this code in your preferred visual studio IDE or visual studio code to manually fix the remaining issues.
Based on the project type, these remaining issues may be different.
Step 4: Test the Code
At this step, you will have a code that is error free and successfully getting build in visual studio IDE. Now you need to execute the code for testing in target framework and environment.
Conclusion
Migrating from .NET Framework to .NET Core is a strategic decision. This involves cost, timing, skills, and changes to the code of application. Any such decision must be reviewed by respective stakeholders before making such a decision.