MADDY MONTAQUILA: Hi everybody.
Thank you for joining
my Microsoft build on-demand session,
upgrading your Xamarin apps to.NET MAUI.
I am Maddy Montaquila,.
Am a product manager on the.NET MAUI team,
and I'm here to give you some tips and tricks
quickly about what to do before you upgrade your app,
and then show you about the upgrade assistant tool
we have in visual studio and on
the command line that can help get
your migrations and upgrades going smoothly.
Let's talk about what.NET
MAUI is quickly if you are new to it.
It is cross-platform native UI.
The biggest change from Xamarin.
If you're a Xamarin developer,
you will get what I mean,
and if you're not, that's fine.
You don't have to worry about it.
We actually use by default a single project,
so you'll hear me talk about
the single project architecture,
migrating things from head projects
into a single project.
That means taking the previous Xamarin Android,
Xamarin iOS apps and putting them on one project.
You don't have to, you can.
That's one of the great benefits of MAUI though.
From that single project,
you can deploy to all of
the different places you deployed for Xamarin,
but also including WinUI and Mac.
You can do Android, iOS,
Mac, and WinUI Windows apps.
It is general availability as of build last year,
so we are now a year old. We're really excited.
We've come a long way from just in the past year,
especially when it comes to
ecosystem readiness for migrations.
We're really excited to share this with you.
If you go to the longer build session
about.NET MAUI in general,
you'll hear some stories about
customers who are already shipping MAUI apps.
But this is all lightening demo and I'm
already rambling too much, so we're going to keep going.
But really.NET MAUI is
just a really productive way to
great your native apps for any platform.
Why should you upgrade?
If you're on Xamarin or Xamarin Forms,
you might be wondering why you have to do
anywhere even though it's not so much work.
But why you have to do any work
to just keep your app running?
First and foremost, if you're
not pushing updates to your app,
you don't actually have to do anything.
At some point it will fall out of
support with iOS or Android.
They will ask you to rebuild it,
compile it against latest operating systems,
but you have many years before that'll be an issue.
So if you're not doing anything to
your apps, don't stress out about it.
If you are putting feature updates to your app,
we think that actually
migrating to.NET MAUI is going to end up
being a really good feature update
for you and your customers for a ton of reasons.
One is just the performance,
and a lot of that comes from
decoupling the platform controls from
cross-platform controls which means
that instead of every function,
every MAUI button being really tightly
coupled to the Android buttons on
iOS buttons and Windows buttons,
we make that more flexible.
By default it is, but you can extend those, modify them.
It's a faster architecture,
and it will also let you develop
an alternate app models if
that's something you're interested in doing.
We also have a lot better desktop support,
so multi-windowing, pointer,
click, gestures, all of that great work.
Ton of other stuff on this slide.
You can pause this video and read
it more deeply if you're interested,
but I'm not going to go into it for the sake of time.
One thing I wanted to show is
this quick performance video.
We are seeing incredibly great startup time changes
between MAUI and Xamarin.
This is a MAUI app file
new versus the Xamarin Forms file new.
It's almost 35 percent faster in startup,
which is pretty significant.
A really heavy real-world app we're
seeing the startup time is still under a second,
which is an awesome startup time,
generally anything under a second
we're pretty happy with.
Performance is a really good thing
, all customers love it.
That's part of the reason we suggest upgrading to MAUI.
Do you need to rewrite your absolute leverage MAUI?
No. We'll talk about how you can do it in
your existing code base shortly.
What happens to Xamarin Android and Xamarin iOS?
If you wrote something that doesn't have Xamarin Forms,
then you might not want cross-platform UI with MAUI.
That's okay. We just have.NET
for Android and.NET for iOS.
It's really not a features.
It's just like.NET can target those platforms.
Those things will upgrade and work perfectly fine.
When should you start trying to upgrade?
The Xamarin end of life is May 2024,
which is a year from now from Microsoft Build 2023.
Like I said earlier,
if you're not rebuilding or pushing updates to your app,
the store will still accept it for a while.
New apps have to be compiled
for Apple against the latest iOS.
If you're building something new,
you should probably try to ship
it with MAUI right off the bat.
But other than that, you should get up-to-date.
You should try and make sure that you're out of
old Xamarin Forms three dot something
and relatively modern with the code you're pushing,
start valuing your migration so that within
the next year you can go ahead and
complete it and ship it to your customers.
The thing about all of these upgrades is
that every customer is different and you know
your app and your customers and
your busy season or risk season,
all of those things, you know them best,
so we wanted to make this really flexible for you.
Some of my tips and tricks.
Couple things, again,
pause and screenshot if you're
interested in going into this deeper.
But I think the most important things for you to do
are get rid of anything unnecessary.
We've shipped a ton of new controls and
properties in both Xamarin and MAUI.
Some of your customer renderers
you wrote back in the day,
you might not even need anymore.
You might as well just get rid of those.
Also inventory your NuGet packages.
If there are packages that you
really depend on that are core to your app,
you should really check if they
have a MAUI compatible version.
If they will need to be recompiled for MAUI,
if there are alternatives, you can switch out to.
I have more info on that on the next slide.
Do not panic,
and that is my number 1 piece of advice.
Don't just stop working on your app until
you migrate because you're worried about it.
That's never good.
I have an email at the end, you can
reach out to us with questions too.
Little bit more about the NuGet packages and libraries.
Great news is that non-UI specific packages will not
have to be recompiled
if they're built off of.NET standard,
except Xamarin, iOS-specific ones need to be recompiled.
There was a minor change, but
that should be really easy to do.
You are also able to just fork
libraries and do that yourself if necessary.
Libraries that have UI components.
Something like extending frames or whatever,
those library owners will have to update
the namespaces and do MAUI compatibility work,
make sure that their layouts are tested.
Almost all of the popular control vendors have
MAUI capable things out in the world now.
Again, that's another thing we have more details
on in the broader MAUI session.
But definitely check that out.
Again, if the UI component you're using is open-source,
you can just fork it and recompile
it if necessary if the maintainer won't do it.
But this is probably
the biggest upgrade blocker when it comes
to preparing to actually to your upgrade.
I always say start your inventory,
get your Excel spreadsheets or whatever it is going,
and that's a really good place to start.
Let's look at how you can use the.NET
upgrade assistant in Visual Studio to
jumpstart and really make your life easier when it
comes to getting things over to MAUI.
I'm going to open Visual Studio.
This is a Xamarin Forms up.
This is an app I've worked on for
a very long time as for demos.
It's actually relatively out-of-date.
I have not updated it to any of
the most recent Xamarin Forms five service releases.
It is called PlantLady.
It tells you when to water your plants.
There's not much going on in it.
Again, like I said earlier,
and I will say probably three more times,
you know your app, your codebase,
your product best,
so this might not look exactly like.
In fact, it probably does not look
exactly like your app and your product.
I'm just giving you the broad strokes for
you to go in and fill in the gaps with your knowledge.
Let's talk about this upgrade assistant.
This is a separate extension I
downloaded into Visual Studio.
If I go to Install, I
have this.NET upgrade assistant here.
That's it. Very cool.
I start share online, downloaded it,
set it up, good to go.
What that does is when I right-click on a project,
it gives me this upgrade option.
Right here I right-clicked on my Android head project,
so that's the Android-specific
Xamarin Forms project and I clicked "Upgrade",
and that's what gives me this UI here.
There's also a command line version.
It has slightly different features.
If you are on Mac,
you can use the command line because this
doesn't exist for Visual Studio or for Mac right now.
Cool. What this supports is Android and iOS
migrations because UWP is not
the backend for Windows for MAUI, WinUI is.
That's a separate whole thing.
We'll talk about that another time.
I can just download this project and not worry about it.
But there are a ton of different ways you
can go about doing your migration.
First and foremost,
you want to start with your head projects.
They reference the Xamarin.Forms
projects. Let me zoom in here.
Your head projects
S1, Android, iOS.
You want to start with migrating these,
and then you want to migrate your MAUI one.
Your Xamarin.Forms one to MAUI last.
But when you right-click "Upgrade," it gives you
two options, in-place or side-by-side.
If you want to maintain head projects,
I would recommend in-place.
For this Android app,
I'll click "In-place Project Upgrade."
You can pick the.NET you want to upgrade to,
I'm going to go with.NET 7
because I'm cool, I'm on the edge.
Then you can actually go in and select
the individual components you want to upgrade.
If I didn't want to move over any of my resources,
if I was going to move over to the way that MAUI
does images which is all in
this single project, I can just uncheck that.
Otherwise, I can just migrate it all. Upgrade selection.
Upgrade is the word, not migrate.
I'm sorry. You'll see it
checks all these things off as it goes.
That was super fast,
anytime you make project file changes,
it is going to unload and reload
things in the solution explorer,
so that's why you see any flashing
or anything happen there.
But at the end of this whole process,
it shows me everything that's
been upgraded and the things
that it checked that don't actually need to be upgraded,
for example, all of these images.
Then I can go ahead and I can do the same thing
to my Xamarin.Forms app,
I'm not going to do the iOS one for the sake of time.
This is another place where you can get interesting.
You can do the in-place project upgrade,
upgrade the same thing, in-place.
One thing that I've seen a lot of customers like to do is
actually use the side-by-side project upgrade,
which lets you move it all into a new MAUI project.
If you decide that you at some point
want to start using the single project architecture,
this is one of the best ways to do it,
I think. You can do this.
You can create a new project or an existing project,
I would create a file new MAUI app,
and name it what you want to name it and
migrate into the existing project.
But for this, we'll just do new,
and then PlantLady MAUI. Right next.
Pick the.NET I want,
and then I tell it again what to upgrade in.
I want everything from my Xamarin.Forms app.
I will do that, it will load,
show the same stuff it showed for Android,
we'll give it a few seconds.
Check, superfast,
and then I will have a MAUI app at the end,
I will have a new project in the solution,
that is a.NET MAUI app,
where it took the code from my Xamarin.Forms app,
and moved it into the different project.
This will go and create
a new project for me and do all the same types of
transformation steps it did with the Android project,
including it will take
any NuGet packages and
update them to the MAUI-related ones,
when it comes to Xamarin.Forms, Xamarin Essentials.
It will also go into my XAML files,
my C# files,
and transform namespaces from
anything that says Xamarin or Xamarin.Forms to MAUI.
It will fix certain API changes,
we call them transformations.
There are a bunch of details you can
get in the output pane here,
from upgrade assistant,
so we'll see it adding [inaudible] statements,
Microsoft MAUI down here,
adding Microsoft MAUI controls to the file so you can
go in and see exactly what it's doing to your project.
Then you're left with that project at the end,
sometimes you do have to go ahead and
reload your solution explorer.
What we'll do is we'll do this to show the new projects.
We'll go in a folder view,
and we'll see we now have PlantLady
MAUI and PlantLady.Android,
the updated one are in here.
This is just a MAUI app,
what's great is I can go and add
a folder to PlantLady MAUI.
I can call it platforms,
and I can start copy-pasting over things from
my Android and iOS apps that I've migrated,
and start to use that to get
the single project architecture that we love with MAUI.
If you don't want do that though, that's totally fine.
If I were to build this right now,
there probably would be a couple of errors.
That's because we don't do
everything for you with upgrade assistant,
we get you most of the way there.
What I recommend is just building your app,
seeing what errors, fixing
those things, and trying to build again.
It's an iterative process,
what's great about this upgrade assistant tool
is that because it's an extension,
we can ship updates to it all the time.
As we identify really
popular transformations people are doing,
we will push updates.
To download the upgrade assistant extension,
you can search in
the Visual Studio extensions or you
can go to the marketplace website,
and find it. It's called upgrade assistant.
The command line upgrade assistant that I mentioned,
it's just on GitHub, it's open source.
Feel free to grab that and follow the instructions there,
that's the one that you can use on
Mac or in the command line so if you're
in different machines where you
might not have a full VSID.
As promised, I mentioned
there will be a way to get in touch with us.
Please e-mail maui-upgrades@Microsoft.com,
with successes, trials,
tribulations, any pressing questions.
Anything you want us to know.
This is not an official support alias,
the PM team, there's a handful of us.
Many of us are in person at Microsoft Build.
We are going to be monitoring this and looking
for stories and critical issues,
and what trends and
common things people are bringing up to you.
If we don't get back to you right away,
I'm sorry, that's why.
But just know that we are reading these e-mails,
and we are using that feedback that you're ascending
us to make better product decisions,
whether it's with MAUI or with
the upgrade assistant, and everything else.
Thank you so much for joining.
Definitely reach out to MAUI upgrades or my e-mail
maddy@Microsoft.com with any questions,
and I hope you enjoy the rest of Build whether
you're in-person or just hanging
out with the prerecords or virtual,
there's a lot of amazing content
from all the different teams this year.
I hope you enjoy it and thank you.