First things first, .NET 6 RC1 and .NET MAUI Preview 8 got released this week but the big breaking news is that .NET MAUI will be ready for Production use (General Availability) only by early Q2 of 2022 (next year) and NOT as originally planned with .NET 6 GA by Nov 2021.
This is definitely sad news for all those Xamarin/.NET MAUI developers who wanted to leverage this brand-new architecture. Hopefully by that time, if additional targets such as Linux/Wasm gets onboard, it would be worth waiting.
And as updated on the .NET MAUI GitHub status wiki, 3 more previews are planned, one every month, till the end of this year and then RCs spanned over Q1 of 2022.
Coming back to this Preview 8 release, the first noticeable change is that workload installation is now integrated into the Visual Studio Installer starting from VS2022 Preview 4. Next, the target API for Android has been pushed to API 31 (Android S). Then, OpenJDK 11 is required to build the Android app. And then, the Host Builder pattern starts to appear in the App startup. And finally, last but not least, Windows is now part of the Single project. Yes, no more multiple projects, just one single project for all 4 targets.
I’m using VS2022 from Preview 1 and I didn’t uninstall Visual Studio to upgrade to Preview 4 / .NET MAUI Preview 8. And below are the steps that I followed for a seamless upgrade.
If you’re installing Visual Studio 2022 for the first time, then make the necessary selections, referring to the below screenshot, right before you start the installation. And you can skip the VS update steps mentioned below.
Kindly note all highlighted commands specified below are to be executed in an elevated prompt.
- First uninstalled the Preview 7 workload of .NET MAUI using the command
dotnet workload uninstall maui. This is to ensure it doesn’t interfere with the recent one
- Installed .NET 6 RC1 downloaded from this official .NET Downloads page and it effectively removes the previous version
- Installed OpenJDK 11 for Windows (x64) from the official OpenJDK Downloads page
- Since Android Studio is already installed in my machine, launch SDK Manager (option available in the top right kebab (triple dot) menu in the launch screen). In the left pane, System Settings section -> Android SDK, then select Android 12.0 (S) – API level 31 in the right side pane and installed it. Refer below screenshot. If you don’t have Android Studio installed, get it from here
- Then proceeded with VS2022 Preview 4 update, launched Visual Studio Installer and initiated the Pending update
- Post Preview 4 update, a Windows reboot was necessary
- Once OS restarted, again launched VS installer and using the Modify option, selected the highlighted Workloads and Individual components necessary for MAUI development. Refer below screenshot.
- Then updated the .NET MAUI Check tool with the command
dotnet tool update --global redth.net.maui.check. Rather, if you want to install it, replace the
installin same command.
- Then invoked the
maui-checktool, an utility from previous step, to ensure everything is set right and it checked and updated a few missing pieces. Follow the on-screen instructions as it may vary from instance to instance
- And then invoked the
dotnet workload listcommand to ensure that MAUI is listed as a workload
- Finally, to run Windows targeted WinUI application from the unified Single project, installed the Single-project MSIX Packaging Tools for VS 2022 extension from the VS Marketplace
- At last launched Visual Studio 2022 Preview 4 and found that only .NET MAUI Class Library project is of Preview 8 (Purple coloured icon) and others were still from earlier Preview. If you come across this issue, just open the command prompt and execute this command
dotnet new --install Microsoft.Maui.Templates. This will install the templates from NuGet
- And importantly for Item templates and Code snippets, updated my .NET MAUI Project and Item Templates extension from within VS Extensions dialog. You can get more details on this extension from this article
- If you would like to develop apps for iOS/macOS (via Mac Catalyst), then install latest Xcode 13 on the Mac Build Host machine (of course, .NET 6 SDK and .NET MAUI SDK is also required there too – .NET 6 SDK can be downloaded and installed from the URL mentioned in Step 2 and .NET MAUI SDK can be installed with
dotnet workload install mauicommand).
- Since Visual Studio for Mac is getting revamped, .NET MAUI App can be developed from macOS using Visual Studio Code and Comet for .NET Mobile extension. To know more on this, take a look at this article.
Will do a follow-up article (now available to read) on the new features in Preview 8 and the differences with the project structure of the earlier preview for a deeper understanding.
Happy coding. Stay connected as we continue to learn and share the experiences from this exciting journey of being a software developer.