Revolutionizing Cross-Platform Development: Migrating UWP Apps to .NET 9
Microsoft’s Journey to Windows App SDK and Win UI
Microsoft’s journey to the current Windows App SDK and Win UI as an integrated framework for building .Net desktop applications has not been easy. The current platform integrates modern tools and projects into a familiar framework, but legacy code built on the Windows 10 Universal Windows Platform (UWP) is difficult to upgrade.
The Challenges of UWP
The Universal Windows Platform, which inherits the WinRT model introduced in Windows 8, was designed to support the new Windows API and the Microsoft Store. However, the problem is that it ties distribution to the Microsoft Store and depends on Microsoft’s application approval process and its own payment platform.
Evolution of the Platform
Over time, the platform and store have evolved, first allowing Win32 applications and games, and now adding support for third-party payment and distribution platforms. The current model is designed to be flexible and compatible with the latest .NET features.
Go Ahead with AOT
.NET 9 will be released in about a month. The first release candidate and a beta version of Visual Studio that supports .NET 9 are now available. As part of this release, Microsoft is also releasing additional tools to port older UWP-based applications to the .NET 9 platform, allowing them to take advantage of new features like native dictionary compilation (AOT).
Import UWP into Windows App SDK
Upgrading UWP applications to Windows App SDK takes time. This takes longer, especially if you rely on third-party libraries and components that have not yet been updated to Windows App SDK or Win UI 3. You can distribute it through the Microsoft Store, but then you will not be able to use features like native AOT.
Introduction to UWP in .NET 9
As always with preview code, setup is a bit complicated. First, let’s start with the latest preview build of Visual Studio 17.12. Once installed, it uses the Visual Studio standalone installer to activate the Windows application development workload. It also adds the UWP tools and the latest Windows 11 SDK in the Others section of the installer.
Working with UWP in .NET 9
You can now work with UWP in .NET 9 using new project templates. It is probably easiest to start with a blank template and import existing code and XAML. It works almost identically to the original UWP template and prepares you for the Win UI migration.
Challenges and Limitations
The process of using a UWP project in .NET 9 is similar in many ways to previous versions of .NET. However, you need to make sure that all of your code (even the libraries you’re using) is compatible with native AOT, and while this is necessary, it can be a complex and time-consuming process.
Conclusion
Microsoft’s tools for supporting UWP in .NET 9 are a significant step forward in helping developers migrate their existing code to the latest .NET platform. While there are still challenges and limitations, these tools provide a clear path forward for developers who want to take advantage of the latest .NET features and technologies.
