Location>code7788 >text

UWP Modernizing UWP Apps with .NET 9 and Native AOT Support

Popularity:138 ℃/2024-09-19 11:38:58

Microsoft is previewing UWP (Universal Windows Platform) support for .NET 9 in a blog post (September 11), offering existing UWP developers a way to modernize their apps with the latest .NET and native AOT. This comes as the company urges developers to switch to the Windows App SDK and WinUI 3, .It is possible to make existingUWP Developers Modernize Their Apps with the Latest .NET and Native AOT

预览 UWP 对 .NET 9 的支持

"Are you a UWP app developer considering migrating to the Windows App SDK and WinUI 3?" Sergio Pedri, a Senior Software Engineer at Microsoft, today posted on DevBlogsA blog post ofAsked in. "Or want to take advantage of the latest version of .NET and native AOT? or maybe you've been struggling to reference the newer versions of your favorite libraries because they only include support for .NET 6 and higher? Well, look no further! This preview UWP support for .NET 9 provides a way to modernize UWP applications with the latest version of .

The Previews are not any new features or functionality for UWP, but rather an updated set of tools and components that are part of .NET, Visual Studio, the Windows SDK, and more. They allow developers to build UWP applications using the latest versions of .NET and C# to modernize their applications with .NET 9 as they consider moving to WinUI 3.

 

UWP was launched with Windows 10 in 2015, realizing Microsoft's vision of a unified application platform across all Windows devices (PCs, tablets, Xbox, IoT, HoloLens, etc.). Various issues and factors stalled the project, and Microsoft introduced a Windows UI library called WinUI 2, a UI framework for the UWP, and WinUI 3, an evolution of WinUI that separates the modern UI framework from the UWP and makes it usable for both UWP and legacy Win32 apps (via the Windows App SDK). Part of the impetus for stalling UWP development seems to be Microsoft's shift to focus on native Windows app development, which is now available through a dizzying array of options, including WinUI 3, Windows Forms, WPF, Xamarin, MAUI, and more:

Microsoft says the main goals for UWP support for .NET 9 include:

  • A better migration path for UWP developers who wish to migrate to WinUI 3.UWP support for .NET 9 provides an incremental path to WinUI 3 without having to perform the entire migration in a single step (meaning updating all .NET runtimes as well as the entire UI framework and application model). By allowing you to focus on upgrading the .NET runtime independent of the UI framework, as well as the application model, and modernizing the codebase with advances in .NET, the migration can now be split into two "checkpoints". First, migrate to .NET 9 and get the application on Native AOT (this already needs to be scenario dependent). Then, after ensuring that the first part of the migration was successful, you can focus on switching from UWP XAML to WinUI 3 and the Win32 application model. This approach makes the migration more incremental and less risky. We are currently working on migrating to .
  • Enables developers to remove dependencies on .NET Native so they can benefit from the latest .NET and C# features, regardless of their application model.If you're currently oriented towards UWP because for some reason you can't migrate to the Windows App SDK and WinUI 3 (either because the Windows App SDK doesn't support certain key APIs or because you don't yet have the resources to perform a full migration), we still want to allow you to be compliant with all other Windows UI frameworks. This update reduces the friction that UWP developers encounter when trying to modernize legacy apps with older libraries from the ecosystem.

"Whether you're migrating from UWP to WinUI 3 or just want to be more productive on your application's existing UI framework, this preview lets you modernize to the latest .NET and C# and take advantage of recent tooling enhancements to simplify your migration process," said Pedri.

This extensive post goes on to detail how to get started, create a UWP .NET 9 project, project details, and more. As for upcoming content, a XAML designer in Visual Studio is in the works, while MSTest will also add UWP support for .NET 9, WinUI 2, support for the Windows Community Toolkit, and more.

A cautionary note provided by Pedri: "As we mentioned in the blurb, UWP support for .NET 9 is available in preview, so expect some rough edges as we work to improve the developer experience! We hope that in the long run this will become the preferred way for UWP apps to use .NET and C#, and that as many developers as possible will be able to upgrade their existing UWP apps from .NET Native to the latest .NET and Native AOT.


Microsoft's tweak has surprised many legacy UWP app developers, meaning that they can upgrade their existing UWP apps to .NET 9 without having to fully migrate to the complex and time-consuming Windows App SDK, which brings a number of under-the-hood benefits. UWP is a mobile app framework that has been nearly abandoned by Microsoft and is stagnant at .NET version 6, so migrating UWP NET version 6, migrating UWP apps to the desktop-based Windows App SDK can be challenging.

NET 9 support for UWP initially, Microsoft hopes to guide developers in upgrading their apps incrementally, starting by modernizing the underlying codebase, removing the dependency on .NET Native (which is stuck at the .NET Core 2.0 feature level), tapping into the latest .NET and C# features, and gaining significant performance improvements.