Xamarin to MAUI Migration – Part One – Why and How to Prepare

How to start migrating your Xmarin App over to MAUI and DotNet 7+

Posted by Clifford Agius | CA-Software Ltd on Thursday, January 12, 2023

TOC

Why?

The biggest question I have been fielding recently is should I upgrade a Xamarin app to DotNet MAUI (Multi-platform App UI) and my answer until recently was there isn’t much in it or there are still a few issues so hold off for now.

However now that NET7 is released, and MAUI is now fully released and fully featured it makes sense to at least start looking and planning an upgrade for Apps. The main reason behind this is that Xamarin will no longer receive support after 1st May 2024 but more importantly the latest SDK’s it will support is Android 13 and Xcode 14 which are the current latest versions from Apple and Google but for how long?

Android and Xcode normally update late summer each year so really Xamarin will be outdated late 2023 as it will no longer be able to support the latest versions and devices. This means that if you have an active App you need to take the time NOW to start the migration process as it’s not a quick and easy process and in this post I hope to give you helping hand in starting the process, sadly however I can’t do this in too much of a deep dive as every project will be different. I will show where to start and useful resources that will help you along the way.

Also by migrating to MAUI from Xamarin you gain the ability to target Desktops with WinUI for Windows and MacOS on the Mac side, all with very little in the way of changes for most apps which is very cool and depending on your app you can also target Tizen which gives you access to all the Samsung smart devices. Another advantage is that with MAUI you can use Blazor in your App which allows your Web Team to bring their skills into the Mobile world or just use that section from the company website instead of re-inventing it in a mobile App.

If your reading this and wondering what is this MAUI thing or it’s all a bit new and you want a bit of a deep dive, don’t worry we have you covered with a 3 part deep dive series Here

Where to start?

The best place to start is to plan a pause in any active development of your application as any work you do on the old Xamarin App could (Read probably will!) cause issues in the migration so plan a stop so that you are planning for success, you can then build a Story for the migration.

Now make a branch for the migration work in your source control, sounds obvious I know but it’s painful if you don’t (Ask me how I know! 😢), but as you will see later there will be some huge changes to the project’s Solution so you will want to be sure you can step back if things do go quite as well as you would wish.

The next step is to make sure your current App is targeting Xamarin.Forms 5.0 as this is the best starting point and where the team have created helpful tools. This hopefully will just be an update of the NuGet packages but depending on your App’s age as well as it’s need it could be a little more work.

Update the Xamarin NuGet’s

A great starting point is the official documentation Here which at the time of writing takes you to the MAUI Github repo as these steps are yet to be added to the Docs.

Visual Studio

This part is really important, but MAUI development and the SDK/tools all live in Visual Studio 2022 on both Windows and Mac, so you need to be on this SKU. Yes, you can view the code files on VS19 but you will not be able to build/Debug/Deploy, so if internally your company are not yet on VS22 you can use this as the case to management for the upgrade 😜.

The good news is that VS19 and VS22 can be installed side by side and it’s what I have on my dev machines, so you have the confidence of being able to switch back to VS19 if needed but I must admit I have not opened VS19 for a while now.

If you are installing VS22 make sure you install the MAUI and Xamarin tooling as you will need both for this to work and the Xamarin tools are not checked by default which catches a lot of people out.

Visual Studio Installer

You can to save space remove the Xamarin tooling after the migration, if you not sure how to do this I refer you to the MAUI deep dive series

Rider

If you’re a Rider user you need the latest version, however as I am not a Rider user I can’t comment on which is the minimum version you need but there is a few blogs Here from the JetBrains team that can help you.

3rd Party Library’s

Most if not all Xamarin App’s make use of 3rd party library’s from NuGet and why wouldn’t you there are so many great tools to be used from the rich ecosystem and community. The problem is that some of these have not been updated for use with NET6+ yet and may never be.

However, the most popular packages have or soon will be as you can see from this slide published by the Xamarin/MAUI team back in November 22:

Popular packages

The best approach though is to break down the list of NuGet’s used and if the package is a Non-UI tool/package that targets .NET Standard it should just work, if it’s a UI Component then you can check if there is a MAUI version or if you can create a replacement in MAUI.Graphics thus removing that dependency.

My best advice here and what I have done on client projects is to make an SBOM (Software Bill Of Materials) this is just a simple list of all the Library’s and NuGet’s used in your project. This is not only great to build and keep updated for processes like this but it’s also a great resource to have in your Repo so that if any security alerts come out for some Library you can quickly and simply check if it affects your application.
I Listen to a great podcast called Security This Week where this was first introduced to me and have implemented it in Excel for all my projects, it’s super simple, takes <1hr and means I have a place to check for security vulnerabilities.

Now you have your SBOM you can check these to see what just needs updating for the MAUI migration and what will leave holes in your App like say a missing whizzy tool that makes an animation work etc. You can then add into your planning how you will replace this or change the App design such that it’s not needed anymore. I have found that on my App’s this has been a great time to look at the design with the client and with the advances in MAUI Graphics and other library’s I have been able to remove some dependencies and improve the app so double bonus.

Custom Renderers

What about all the hard work you have put into that custom renderer to please the business and to show the graphic designer how good you are, or just to get around some quirk of the OS…

Well, it’s not a blocker to migration but potentially a lot of work if you have a lot of them, and thankfully there are great resources that can help you.

Gerald Versluis - Use Custom Renderers in MAUI

MAUI GitHub repo - Porting-custom-renderers-to-handlers

DevOps

Then there is the DevOps process to think about this will need some major changes as well and although not mentioned above as it depends on your internal systems, but GitHub Actions or Azure DevOps would be just as big changes required as the migration of the app.

This again needs planning and in my client cases I have set-up a separate DevOps process from scratch before migrating the App so that I know that stage is complete and tested working. You can do this with a simple File New MAUI app to prove the process and release gates etc.

Conclusion

There is a lot to the migration, but if you take the time to plan and prepare the actual migration should go smoothly, I’ve migrated a few apps now and just like any decorating it’s all in the preparations.

Part of the planning should include making that SBOM I mentioned which will help not just with the migration but also in maintaining the App going forward, but I have also found that as an Excel sheet it’s easy to share with the business to build the story around the migration.

Lastly reach out and let us know how you get on or to share your hints and tips, and if you hit a real stumbling block maybe we can help or alternatively reach out to the MAUI team on socials they are willing to assist as well.

I hope it’s a good migration for you.

Happy coding.