filmov
tv
.NET Framework 4.8 to .NET 6 migration Every Developer Should Know | HOW TO - Code Samples
Показать описание
#coding #codingbootcamp #softwaredeveloper #codeyourfuture
I was recently tasked to migrate an application with around 150 projects from the “old”It is still supported .NET Framework 4.8 to a recent .NET 6. As the application is still under development and used, the migration should be done step by step over time in iterative steps rather than a big bang refactoring. This video will go a bit into more detail about how I approached the situation and what I learned.
This is a highly subjective post, and there are plenty of ways of approaching it — so take it with a grain of salt and mileage may vary.
The Application
The application itself isn’t that special — at least not from the point of view of the migration. It is a typical 3-tier application with an Angular Frontend and a .NET Framework 4.8 backend. The backend is split into multiple projects, most of them are smaller tools like console applications or library projects. And then there are two ASP.NET Core WebAPI’s and some Windows services that are done in TopShelf.
The Task
As said earlier, the application is still under development — doing the Big Bang was not a viable option. And even if there is no one currently working on the application, it is still not a good approach in this scenario. So I needed a concept to go from .NET Framework 4.8 to .NET 6 step-by-step and in an iterative way. Best case scenario: You have multiple JIRA Tickets that can be done from time to time until the whole application is migrated.
Before we go into detail we have to clarify something really important: Some terminology, because this will be important throughout the whole post.
.NET Standard / .NET Framework / .NET
We have to understand what are these 3 different words.
1. .NET Framework 4.8 describes the “old” .NET that runs only under Windows (I excluded Mono here). It is not cross-platform capable.
2. .NET 6 The “modern” .NET that is cross-platform capable. It is the successor of .NET Core 3.1 and .NET 5.0. It is the future of .NET and the default for new projects.
3. .NET Standard is a specification that describes the API surface of a .NET implementation. It is a subset of the .NET Framework and .NET. It is used to create libraries that can be used by both .NET Framework and .NET. It is not a runtime, it is just a specification.
The last part sounds “odd”. But imagine .NET Standard like an interface (or multiple thousand interfaces and classes) that a client has to implement. The client would be .NET Framework or .NET.
Unit tests
Unit test projects are a bit tricky. You can’t just migrate them to .NET Standard 2.0. Basically .NET Standard is no runtime — so you can not execute your tests. There are two ways — if they only depend on now migrated projects that target .NET Standard 2.0, you can upgrade them to .NET 6. If they are still referencing .NET Framework 4.8 projects, you have to wait until those are migrated as well!
Now that you migration is completly done and well-tested, you can think of all the new things you can do. For example we used Autofac and decided to go with the default of ASP.NET Core. Anyway, I would argue do the migration without much refactoring or introduction of new concepts as it makes it much harder than it could be! Afterward, you can improve whatever you want.
Lots of Great How Tos and Code Samples! Make sure to like and subscribe!
Комментарии