Microsoft has shipped the first preview of .NET 6.0, the first long-term support release of its newly unified application platform, promising native Apple Silicon support, desktop applications on ARM64, and a ton of updates to key frameworks like ASP.NET Core.
Program manager Richard Lander described .NET 6 as "the final parts of the .NET unification plan that started with .NET 5" in a lengthy post on the new release. The preview is available for Windows, macOS, and Linux, though note that the desktop application frameworks, Windows Forms and Windows Presentation Foundation, are Windows-only.
The main "final parts" referred to are the integration of the Xamarin cross-platform tools for mobile and macOS. The Xamarin brand is mostly going away, and Xamarin Forms, for applications that share user interface (UI) code across platforms, now goes by the catchy name MAUI (Multi-Platform App UI). But whether it is really unified is a matter of definition.
The Xamarin technologies are now part of the .NET SDK, though they are optional "workloads", and there is more code shared between Xamarin and other .NET frameworks, including a single Base Class Library (BCL).
That said, there are now two .NET runtimes in the .NET 6 SDK, the CoreCLR (Common Language Runtime), which is the mainstream version, and Mono, which is the Xamarin runtime. The existence of these two runtimes means that some aspects of this unification are cosmetic. Another longstanding issue is that the XAML dialect used by Xamarin and now MAUI is very different from the XAML used for Windows Presentation Foundation (WPF).
Microsoft is also throwing yet another approach to cross-platform GUI application into the pot, in the form of Blazor, a web framework that can run .NET in the browser by compiling the runtime – actually the Mono runtime – to WebAssembly (Wasm). Blazor uses HTML and CSS for the visual controls. Blazor for Wasm in .NET 6 is improved in that it compiles directly to Wasm, rather than just compiling the runtime to Wasm and having it execute .NET assemblies.
.NET 6.0 introduces Blazor desktop applications, which still use web technology but are wrapped to run as native applications. "It is primarily aimed at web developers that want to provide rich client and offline experiences for their users," said Lander.
The container for Blazor desktop application is provided by MAUI, which means you can optionally add native controls alongside or in place of HTML controls. It is also possible to have an "island of Blazor" in other frameworks such as WPF. Blazor for Android and iOS is also planned.
"The main goal for .NET 6 is to support the Windows and macOS desktop platforms, but we will surely have code running on Android and iOS as well, but it might not be fully supported at that time," said Microsoft engineer Eilon Lipton.
The attraction of both Blazor and MAUI is full-stack C# so that developers need only work with C# and .NET. The problem is that Microsoft has too many different approaches, diluting both its effort and its pitch to developers. It is also somehow still missing a lightweight cross-platform GUI for .NET Core.
ARM usage looks set to increase and Microsoft is improving its .NET support by including support for Windows Forms and WPF in ARM64 builds of Windows. Developers can also now target Apple Silicon, which Lander said "required a large enough set of code changes that we are not considering backporting them to .NET 5."
In order to support this new CPU, Microsoft has to meet the requirements of Apple's "hardened runtime" which is intended to improve security. That said, Microsoft will not support universal binaries. "We will not be enabling a workflow to publish universal binaries for .NET apps this release. We will reconsider this need with .NET 7," said Lander.
These additions together with the integration of Xamarin mean that .NET 6 officially targets more platforms than before, now including Android, iOS and Apple Silicon, and Windows ARM64, on top of the existing Windows and Linux platforms.
Another new thing in .NET 6 is single file applications for Windows and macOS, using static linking. Previously, this was only possible on Linux.
Perhaps the most important part of .NET is ASP.NET Core for web applications and microservices. Plans include hot reload, a developer productivity feature where code changes can be applied to a running application without restarting and losing state.
Another feature is Micro APIs. This addresses an issue for new .NET developers – that there is a lot to learn when getting started with the existing Web API framework, based on ASP.NET MVC controllers. The idea is to extract features from the existing framework so that they can used independently, forming a "new lightweight programming model."
Lander described many changes under the covers in .NET 6.0, including better optimisation for container deployment. Another big one is a new implementation of the .NET thread pool, which is now a managed implementation written in C#. One of the goals is that this can be used from both CoreCLR and Mono so that its behaviour will be the same.
The .NET platform goes back a long time. It is now over 20 years since the first preview of Microsoft's riposte to Java and 19 years since its first full release in February 2002. The combination of remaking .NET as the open-source, cross-platform .NET Core, and Microsoft's acquisition of Xamarin for mobile applications, has kept the platform up to date.
Microsoft is promising new .NET 6 previews "like clockwork, once a month" between now and the expected general availability release in November. ®