News
As .NET Core 2.1 Support Nears End, Microsoft Previews .NET Upgrade Assistant
Microsoft recently warned developers that .NET Core 2.1 won't be supported after Aug. 21, after previewing a new .NET Upgrade Assistant.
The two moves made early this month aren't directly related, as the upgrade tool is intended to help developers modernize applications built with the old Windows-only .NET Framework in order to run on the cross-platform, open source .NET 5. However, they do highlight the progress of the .NET unification initiative and the need to keep current.
.NET Core 2.1 arrived on the scene back in May 2018, following up on v2.0's work to introduce tens of thousands of new APIs to the new framework. It was a long-term support (LTS) release, guaranteed to be supported for three years or for one year after the next LTS release is shipped, whichever is longer.
".NET Core 2.1 will be reaching end of support on August 21, 2021 and after this date we will no longer provide updates including security fixes, or technical support for this version. We strongly recommend you migrate your applications to .NET Core 3.1 or later before this date," Microsoft said in a March 4 blog post.
Coincidentally, the company only two days earlier introduced the preview of the new .NET Framework-to-.NET 5 upgrade assistant.
It's a .NET global command-line tool that provides guidance for incrementally upgrading applications. Although it has been around for more than a year, Microsoft just announced it as a preview. The heart of the tool is the GitHub-based, command-line try-convert project, which is bundled with extensive guidance in the assistant.
Year-old documentation referenced above includes this description of the tool:
"The .NET Upgrade Assistant is a command-line tool that can be run on different kinds of .NET Framework apps. It's designed to assist with upgrading .NET Framework apps to .NET 5. After running the tool, in most cases the app will require more effort to complete the migration. The tool includes the installation of analyzers that can assist with completing the migration."
It supports the following .NET Framework app types:
- .NET Framework Windows Forms apps
- .NET Framework WPF apps
- .NET Framework ASP.NET MVC apps
- .NET Framework console apps
- .NET Framework class libraries
In announcing the preview, Microsoft outlined its seven-step process:
- Backup your projects: Ensuring you have a backup (and your code is in source control), means you can easily rollback to a working state if you need to at any point.
- Update the projects to be SDK-style projects: .NET 5 uses a simplified and different project file format compared to .NET Framework. This step uses the try-convert tool that was installed as part of the pre-requisites to move all your projects over to the new SDK-style project format.
- Update the target framework (Update TFM): At this step, the tool will re-target your projects to target .NET 5.0. Read more about target frameworks.
- Update NuGet packages in your projects: Here, NuGet package dependencies are updated to versions that are compatible with .NET 5.0.
- Add template files: For some application models like ASP.NET apps, common template files (like Program.cs and Startup.cs) are missing in older framework app versions, so they are added at this step and simple updates are also made based on recognized web.config or app.config values.
- Update C# source: Now that all your projects have been upgraded to .NET 5 and references upgraded when the tool could help, it's time to make some specific fixes to the C# code.
- Move to next project: If your solution includes multiple projects, this is where you'd move on to working on the next project that was recommended in the beginning.
The open source project's GitHub site provides another take on those steps, illustrated here:
Other migration tools exist, of course, even from third-party vendors like AWS, which open sourced a tool for porting .NET Framework apps to .NET Core on its cloud platform. Another firm automates Visual Basic upgrades.
There is even more guidance available for .NET Framework upgrades, including:
All that guidance is needed because Microsoft has, as is did above, repeatedly warned that there's no magic do-everything functionality to be had -- much dev work may well be required for most projects, certainly big, complex ones.
"Remember, that the tool is not intended to completely upgrade .NET Framework applications to .NET 5. Manual changes will still need to be made because these require knowledge of the app and how it's intended to function," last week's post advised.
"We recommend that once you're finished in the tool, you head back to Visual Studio and attempt to build your code. Look for warnings in the Error List window of Visual Studio to help you identify other parts of your code that might not be supported in .NET 5. You should also check any NuGet packages that might have been updated as sometimes there are breaking changes and you may need to revert to an older version."
About the Author
David Ramel is an editor and writer at Converge 360.