DEV Community

Cover image for .NET 6 Preview 2 (Release notes + New features)
ByteHide
ByteHide

Posted on • Edited on • Originally published at bytehide.com

.NET 6 Preview 2 (Release notes + New features)

.NET 6 Preview 2 Announcement đź“°

On March 11 of this year .NET 6 Preview 2 was officially announced. This new version includes runtime performance improvements in initial versions of .NET MAUI, new APIs, compilers for Apple Silicon and more.

Microsoft plans to release monthly previews through October. Releasing in November the final version of .NET 6, with all the new features, such as enhancements for all .NET applications, including desktop, mobile, server,cloud and IoT.


Support đź’»

This new version of .NET 6 can be downloaded right now for Windows, Linux and MacOS.

As we have discussed before, .NET 6 will be officially released in November 2021 and will be supported for 3 years. Microsoft promises that .NET 6 will be a big change from .NET 5.

The additions that Microsoft promises to bring are:

  • Android
  • iOS
  • Mac and Mac Catalyst for x64 and M1 chips
  • Windows Arm64

Performance 🚀

Microsoft claims that .NET 6 performance will be much higher than .NET 5. That is very likely since we have seen how in the jumps of its previous versions the performance has been increased at the same time that the memory consumption has been reduced.

They also promise to increase the performance of tools and services to ensure that .NET developers are as productive as possible. Below we can see some of the first performance tests. 

Image description


.NET has a lot of experience developing client applications. 👨‍💻

One of the most important parts of what comes to be .NET 6 is mobile development, which is now offered separately from Xamarin. Over time, Xamarin has moved closer to the mainstream of .NET. At this time, with the development of Android, iOS and MacOs it will be integrated into the .NET SDK experience and the .NET libraries will be used.

Microsoft tells us that over the years they have been working to incorporate Mono into .NET, allowing developers to take full advantage of both runtimes without having to worry about compatibility or working with different .NET versions. Microsoft on .NET 5 moved Blazor WebAssembly and is currently using that same model for Xamarin.

Since all .NET applications will now run in the same libraries, Microsoft wants to increase the amount of code that is shared across desktop and mobile platforms. To do this they introduce us to Xamarin.Forms, Xamarin’s cross-platform user interface framework, which is evolving into the .NET cross-platform application user interface. This will allow you to easily write applications for Windows, MacOS, iOS and Android with the same code base. 


.NET MAUI 🔝

They also tell us that .NET MAUI will be added as an enhancement to .NET 6.

.NET MAUI is not just for client application developers. Thanks to all the .NET 6 enhancements, existing Blazor applications will run natively on MacOS and Windows via .NET MAUI.

Another major feature that Microsoft is focusing on is the packaging issue, as there are so many developers with different target platforms, alongside different ways of developing applications. At the end of the day that’s a lot of packages to distribute. They especially focus on applications with the Blazor desktop, as they want that experience to be as seamless as possible. 

Right now Microsoft is looking for strategies to improve the release and version control both locally and in the cloud, as well as on the desktop, so that developers can package, distribute, launch and update their applications on different architectures and desktop platforms. 


Summary of what’s new in .NET6 🏅

  • You will be able to create applications for MacOS, iOS and Android with the .NET libraries.
  • It will allow to create iOS, Android, Windows and MacOS applications from the same code base using .NET MAUI.
  • The ability to share more code and resources between platforms (such as icons, images and more) will be implemented.
  • Ease of running Blazor web applications natively on MacOS and Windows.
  • You can easily package and distribute applications for all the target frameworks you include.

Microsoft ends (for now) telling us the news in .NET 6 telling us that they have made a lot of progress in development and that they will continue to add more features in each Preview of .NET 6.

We are going to dedicate the remainder of this article to dig a little deeper into the new features of .NET 6 Preview 2.


Cross-platform .NET application user interface ✅

From Microsoft, they tell us they have added .NET MAUIs and unique project developer experiences for Android iOS and Mac Catalyst. They also tell us that they have updated their repository with samples of projects that can already be run with .NET 6 Preview 2.


Mac Catalyst ✅

The function of adding the following TargetFramework configuration to any project will be implemented to be able to compile it on MacOS desktop, using Mac Catalyst.

<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
Enter fullscreen mode Exit fullscreen mode

Microsoft tells us that they have enabled a unique experience for .NET MAUI applications. Now what you get is a very clean solution that can be run on Android, iOS, and MacOS. They also tell us that they will add Windows to .NET MAUI in a future Preview.


Shared application icons, images, and fonts ✅

Icons, images, and fonts can be placed in one location in your code, and the .NET MAUI will allow you to work natively on all platforms it targets. These will just track SharedImage or SharedFont in your .csproj file.

<ItemGroup>
    <SharedImage Include="appicon.svg" ForegroundFile="appiconfg.svg" IsAppIcon="true" />
    <SharedFont Include="Resources\Fonts\ionicons.ttf" />
  </ItemGroup>
Enter fullscreen mode Exit fullscreen mode

Both accept wildcards to include all files within one location.

<ItemGroup>
    <SharedImage Include="appicon.svg" ForegroundFile="appiconfg.svg" IsAppIcon="true" />
    <SharedFont Include="Resources\Fonts\ionicons.ttf" />
  </ItemGroup>
Enter fullscreen mode Exit fullscreen mode

Launch applications with Host Builder with MauiApp ✅

They currently have extensions for configuring fonts, services, and compatibility renderers for migrate Xamarin.Forms projects. IWindow was added for multi-window support in a future release. They also aim to integrate library authors and control providers with the .NET MAUI.

public class Application : MauiApp
{
    public override IAppHostBuilder CreateBuilder() => 
        base.CreateBuilder()
            .RegisterCompatibilityRenderers()
            .ConfigureServices((ctx, services) =>
            {
                services.AddTransient<MainPage>();
                services.AddTransient<IWindow, MainWindow>();
            })
            .ConfigureFonts((hostingContext, fonts) =>
            {
                fonts.AddFont("ionicons.ttf", "IonIcons");
            });

    public override IWindow CreateWindow(IActivationState state)
    {
        Microsoft.Maui.Controls.Compatibility.Forms.Init(state);
        return Services.GetService<IWindow>();
    }
}
Enter fullscreen mode Exit fullscreen mode

Control drivers ✅

Lastly, the first controls and properties have been introduced that implement a new controller approach. These include partial label and input, button, and slider and switch implementations. The sample application is HelloMaui, it runs from a single project to MacOS, iOS and Android displaying the current set of ported controls.

Mac OS:

Image description

iOS:

Image description

Android:

Image description

Top comments (1)

Collapse
 
lorena2307 profile image
Lorena-2307

I like to read your articles, they are very original!