Update on .NET Multi-platform App UI (.NET MAUI)
The .NET 6 project started in late 2020 as we were finishing .NET 5 where we started the journey to unify the .NET platform runtimes, libraries, and SDK. .NET 5 proved to be a very successful release, the first of the annual November releases, and due to the pandemic, the first all remote team release. Most importantly, it has been rapidly and broadly adopted. This November, .NET 6 will GA and will complete the unification of the mono runtime into core, have one set of base libraries for all workloads, and provide one SDK and project system with an expanded set of operating system and device targets. We will also release the next version of the C# language with C#10, have made several enhancements to the web stack ASP.NET, and improved the development experience with hot reload everywhere. We are also working on the next major release of Visual Studio 2022. There’s a whole lot more improvements coming with .NET 6 in November. Read the RC1 release posts for .NET 6 and ASP.NET Core in .NET 6.
. All the features we plan to deliver for .NET MAUI will be available in November when .NET 6 releases, but we will continue to work on quality and addressing customer feedback. We encourage you to give the previews a try. The .NET Upgrade Assistant will also support upgrading Xamarin projects to .NET MAUI.
.NET 6 RC1 is a “Go Live” release, meaning you can use it in production and you will be supported. This excludes .NET MAUI packages. The next release of .NET MAUI packages, when .NET 6 RC2 releases, will indicate “preview” in the version.
Thank you for all the feedback, contributions, and excitement that you have shared with us on this journey. Please keep it coming and we look forward to a high-quality release early next year. Now let’s look at some of the new features in this release.
.NET MAUI Preview 8 Highlights
The September preview of .NET MAUI completes some important Visual Studio integrations, namely installing .NET MAUI as a workload in the Visual Studio 2022 installer, and folding the Windows platform inside our single, multi-targeted project. With Visual Studio 2022 Preview 4 you can now use broader Hot Reload support with C# and XAML, and the new XAML Live Preview panel for a productive, focused development environment. Within the .NET MAUI SDK itself, preview 8 includes updates to the app startup pattern, the ability to extend a handler, and miscellaneous other new control capabilities as we close on feature completeness.
Visual Studio 2022 Preview 4 Productivity
When installing Visual Studio 2022 Preview 4, you can now check .NET MAUI (preview) within the Mobile Development with .NET workload. This will bring in .NET 6 as well as the optional workload dependencies: Android, iOS, and Mac Catalyst. When targeting desktop, you’ll also want to choose the Desktop Development with .NET, UWP, and Desktop Development with C++ workloads.
Once installed, the .NET MAUI templates and features of Visual Studio are all available. Live Preview will mirror your running application within the Visual Studio window in a panel you can dock anywhere that’s most convenient to you. The panel supports zooming in and out to focus on every detail of your UI, guides to align elements on both horizontal and vertical axis, and on some platforms you can hover and select UI elements to get sizing and distance information.
XAML Hot Reload now works well on Android, iOS (on Windows via Hot Restart or a remote build host), and Windows. And .NET Hot Restart is working together with XAML Hot Reload on Android, iOS, and Windows too.
When you create a new project, you’ll now see the Windows platform is alongside Android, iOS, and Mac Catalyst within the Platforms folder. To use Windows, you first need to install the Windows App SDK extension for Visual Studio 2022, and then uncomment the TargetFramework node at the top of your csproj file. In a future release, this will be available by default with the extension pre-installed with .NET MAUI.
.NET MAUI SDK Updates
The most notable update that you’ll need to migrate existing applications to is how we implement the .NET Host Builder pattern. We are now aligned with how ASP.NET and Blazor do this with a MauiProgram class that creates and returns a MauiApp. Each platform now calls that MauiProgram.CreateMauiApp. Compare an existing project with the new templates, or the pull request, to see these changes to Android/MainApplication.cs, iOS/AppDelegate.cs, and macCatalyst/AppDelegate.cs.
Sample
MauiProgram:(); } }
Sample of the Android
MainApplication:
public class MainApplication : MauiApplication { public MainApplication(IntPtr handle, JniHandleOwnership ownership) : base(handle, ownership) { } protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); }
Android Updates
Android 12 (API 31) is now the default for .NET 6 applications building for Android. To use Android 12, you’ll need to install JDK 11 manually. Once we update the Android tooling in Visual Studio to use JDK 11, we’ll bundle this dependency by default with .NET MAUI. Until then, JDK 11 may have an unfavorable impact on the Android designer, SDK manager, and device manager.
Android projects now use the MaterialTheme by default. Make sure
Platforms/Android/MainActivity.cs specifies
@style/Maui.SplashTheme or you may get runtime errors on Android. Review the updated .NET MAUI template for example.
Other Changes
Other notable changes and additions include:
- MinHeightRequest, MaxHeightRequest, MinWidthRequest, MaxWidthRequest have dropped the “Request” suffix and the layout system now treats them as true values
- Simplified method for appending behavior to any control mapper – #1859
- Various improvements to Shell theme styling
- Added RefreshView for Android #2027 and iOS #2029
- Added AbsoluteLayout #2136
- Added Right-to-Left (RTL) FlowDirection #948
- Added Button.Icon ImageSource #2079
First thing’s first, remove all previous installations of .NET 6 and Visual Studio 2022 previews from your Windows control panel. Now install Visual Studio 2022 Preview 4 and check .NET MAUI (preview) under the Mobile Development with .NET workload, the Desktop Development with .NET workload, Desktop Development with C++ workload, and Universal Windows Platform.
Now, install the Windows App SDK Single-project MSIX extension. Before running the Windows target, remember to uncomment the framework in the csproj file.
Ready? Open Visual Studio 2022 and create a new project. Search for and select .NET MAUI..
Sad to read that you had to push back MAUI.
Though I kind of anticipated it, because it never seemed the project caught up to the delays at the beginning.
eg. /
With all my love to Xamarin and cross-platform development, I regret to say that MAUI is still a complete failure… Wanted to play with it today. Updated VS 2022 to latest preview version. Created MAUI project – success. But… cannot run on Android, cannot run on iOS… Cannot change Target OS and Target frameworks on project properties page. Repeated all these steps on another computer. Same… Bump… It’s really sad that Microsoft cannot invest enough resources into MAUI development and QAing.
as well as updating to Android 31 did the trick for me. Still, not sure why I had to update templates manually. Also, other issues with changing OS and target framework remain.
As this is an early preview, very little actually works properly with .NET Maui. It will most likely be a few months before it starts to settle down. Maybe take a look when it has GMed and decide if it is a failure or not, rather than judge a preview version.
Hi every body ,
i have a problem with Tools – Options – Xamarin – Android UI Designer :
The ‘MonoAndroidDesignerPackage’ package did not load correctly
– an error occurred loading this property page
-The Toolbox is empty while trying ao add controls to the XAML File
– The Events doesn’t load automatically even when pressing Enter Key+Space Key
IDE: VISUAL STUDIO 2022 COMMUNITY PREVIEW 4.1
Project: .NET MAUI PREVIEW 8
Youtube problem video link:
Github link :
Thanks.
.Net MAUI seemed a god way to go, but, after some research I found Uno platform and even with some similarities they are different.
Why two different ways to do the same ? And even worst, Uno’s approach building UWP upon the native UI frameworks looks better.
Scott,
I was wondering how will we be able to monetize our apps with ads using .NET MAUI or using In-App Billing.
In the past we had to sort of using a plugin or write our own code specific for Android or iOS???
Are you planning pn covering those topics for MAUI Apps?
I would expect you will still implement IAP and ads the same way you did previously.
Hi Scott,
When I download the latest version MAUI and try adding a shape or drawing something in the content page, the application always fail with error in WinUI platform, but succeed in Android (more details:) . Is that mean the apis for drawing on WinUI is not suportted yet? How can I draw shapes on a content page.
As this is an early preview, very little actually works properly with .NET Maui. It will most likely be a few months before it starts to settle down.
Are there any plans to support Linux in the future?
I want to develop a GUI that can build Linux and Windows together in a single codebase.
MacOS is also supported, so why not support Linux?