Upgrading from Xamarin to .NET MAUI

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi all right did anyone just come in that did not see the previous lightning demo anyone okay one don't worry we'll cover it uh you can also go back and watch Alias given that talk a bajillion times and a bunch of different formats so you can always go and watch online somewhere um I'm kind of doing a deep dive on a very specific scenario that she did not demo with the Upgrade Assistant upgrading your xamarin app to.net Maui so if you don't know what.net Maui is I don't have too many slides but I didn't want to show the exact same demo so I have a couple slides it's helpful um it is generally available available we G8 it at build last year so we are now a year old which is very exciting happy birthday to us um and it is a single project system single code base all of the things you need to Target Windows Mac Android and iOS from a single code base if you have a xamarin app or a xamarin forms app it is really the evolution of xamarin and xamarin forms as kind of we've become part of net we change some things that were a long time um you know complaints or feedback from xamarin developers and we've improved them a lot so it is definitely worth upgrading evaluating whether or not um you know it's going to give you something some of the reasons we've seen people upgrade there's a there's a whole bunch of stuff it is not a replacement it is a Evolution you do not have to rewrite your app I think I have on the slide later it's like the biggest FAQ but what we did under the hood was we took the platform controls we decoupled them from all the cross-platform stuff we were doing so you can actually extend them yourself you can do you can rip out the platform specific renders we gave you in xamarin you can put your own drawn UI controls you can use third-party packages you can do them in different app models if you wanted to do like a model view update Style app instead of mvvm with xaml uh better desktop support so we added Mac as an official platform and we moved from uwp to win UI there's a better app building pattern there is a single project instead of multiple projects unified with that blah blah I can go into this forever um my favorite thing though is it's fast so the app startup faster look at that and that's just the file new app so if you take that um and extrapolate it to a much larger app that means you get even more performance gains which is pretty good so definitely worth it um I do not have the support slide in this presentation but if you are interested in learning more about the support timeline for xamarin we do have a slide on it in the Thursday session all things client with mobile desktop.net Maui something or other tldr or xamarin is going to go end of life in May 2024 that does not mean that you cannot use it it just means we are not going to support it anymore we are not going to give it the latest IOS and Androids so you want to get onto Maui by next summer if you think you're going to be actively pushing updates to your app so FAQ is about upgrading it is not a rewrite the first six months since we announced Maui I think every time we got on the phone with a customer it was oh my gosh why are you expecting me to rewrite your app you don't have to rewrite it the xaml is the exact same as ammo flavor some apis we changed that happens we got rid of some of the obsoleted code that's been hanging out in xamarin for a while other than that um it's not a rewrite there are some changes we'll talk about it what happens to xamarin Android or xamarin iOS we are just calling them.net for Android and net for iOS right so people who are not xamarin forms users have been freaking out you killed xamarin Android no it's just.net for Android it's it's all good everything's gonna be great you can also upgrade those projects it's actually even less work than trying to upgrade into Maui um and then when should you start trying to upgrade I our suggestion is do an evaluation of your app see where you're at if you're going to be pushing updates if you need latest operating system support you're going to want to do it sooner rather than later if it's just an app that's been there and you don't really need to worry about it and it's probably going to fade into the Oblivion in a few years anyways don't worry about it but I would say get up to date make sure that you're running on some of the relatively newer xamarin xamarin forms builds and start evaluating what you're up to and what you're going to have to do to upgrade bunch of different things that you can do you can have your summer intern now that it's we're coming into the summer go through and start cranking through these for you remove unnecessary custom renderers so how many of you um have a xamarin forms app okay good and how many of you have had a xamarin forms app since xamarin forms came out yeah well I know you did um so it's changed a lot we've added a lot of features and so a lot of the things that you had to do custom and by hand in 2015 2016 2017 2020 you don't have to do anymore we just have them in the box so that's the number one tip I have for people is just go in and see what we shipped that you worked around back in the day that as we matured as a product you don't need to do anymore um a couple other tips on here the other big one to call out is um inventory or nougat packages so Olia mentioned the same thing if you have packages that are not going to be supported with the latest.net you either want to move off of those or be ready to um yeah Fork your own version of them and update it yourself so lots of options the other thing I say is do not just like stop working on your app and neglect it because you're like we're going to migrate it anyways I just don't need to work on it that's also not a good idea I should also really put on the slide do use git or something but it's fine so packages non-ui specific packages will just work except for ones that are specifically hitting some xamarin iOS related stuff we changed like one thing and they just have to be recompiled that's all it is it's all at build time where the um the interesting stuff happens with Maui libraries is UI components the namespace has changed right we went from xamarin forms to microsoft.maui so they have to do that and make sure that their layouts still look the same most of the major controls we see we you know have a huge list of nougats that people use regularly most of those are updated now this time last year it was a very different story even at net confident November it was a very very different story now libraries are not the biggest blocker to migration anymore which is great so it often was it still can be depending on what packages you're using but um it's pretty good pretty good so let's take a look at how you would do this with a xamarin app I'm gonna let my screen do all of its things okay so I'm not going to demo this with a real app because for simplicity's sake first of all I know that every single person in this room your app is architected in a different way so trying to show you an example app is not going to be helpful because everything about upgrading your app is based on your code base your patterns how you want to do it your your skill set your expertise all those things so this is just a file new flyout app you can see it's a xamarin app so it's got my.net standard project and then it's got my Android and iOS head projects we call them and so if you hear me say head project that's what I mean these are the head projects or the platform specific projects um and so there's a whole bunch of different ways right off the bat that you can do your Maui migration we've seen people just migrate everything in place right upgrade each project upgrade the Android project to done at seven iOS project and then upgrade those xamarin forms project to Maui we've seen people start a new project and copy paste it over it's really flexible if you want to use the single project architecture which is the new Maui thing that you don't have to have head projects anymore we think right now the best way to do it would probably be to create a new Maui project and start moving things over so I'll show you how to do that with the Upgrade Assistant because it is very nice so right click upgrade I don't know if Olia showed I stopped out from it for say some hi to someone in the hallway of course right as she started um there's just an extension the.net Upgrade Assistant extension you search it you download it and then in all your projects you will have right click upgrade so my recommendation if you are going to upgrade in place is to start with the head projects get those ready to roll and then do the xamarin forms project last that just keeps Visual Studio the least angry with you that's yeah as only in us and then if you want to go into the single project architecture I actually like starting with the Maui project and moving the platform specific stuff later so up here I'll do side by side and I can actually create a new Maui project here currently this creates a library project which we want to fix at some point um we will do this soon and because it's an extension the updates ship a lot more frequently than the visual studio updates just FYI so I'll create my new project what I wanted to do down a seven and then I can check which of my Mount of my xamarin forms project I want to upgrade into that Maui app so I'll keep it all checked um what this is going to do is go in and look at all my namespaces look at my CS proj look at my nougat packages it's going to take xamarin forms out and make it microsoft.maui it's going to take xamarin Essentials out and make it microsoft.maui because it is built in to Maui now it's going to go in and update namespaces here my view model stuff my view stuff all these things scroll down where's what I'm looking for and it's going to add the entry point to my app Maui program.cs so oh Siri I was not talking to you what time is it oh good I have plenty time left okay so this is a now a single project Maui app that I have created it does not have the platforms folder so that's one thing we you can do is you can actually create a blank Maui project get it set up and then migrate into it if you'd prefer to not just have Upgrade Assistant make the new project for you but then what you can do is take these and either upgrade them in place or start copy pasting things over into that new project so I'll do upgrade um side by side existing right actually I changed my mind every time I do it I haven't decided the best way but we'll go in here same thing oh this is gonna overrid the project file no what I will do with the Android and iOS ones is I upgrade them in place first upgrade hold on go away go away uh great um I'll upgrade this to.net7 next upgrade the whole thing and then what's nice is I don't actually need most of this stuff anymore so I could just leave this as a separate Android project that is now my Maui app depends on it but I could also create a platforms folder here and just copy paste the necessary files in from Android to the Maui project if I want to use single project so those are all options um and again it's really flexible and the reason I'm showing you all the different ways you can do it is because I know everybody's app is different so if you know there's a lot of different things you can do we're also continually working on this it just released the Maui support a couple weeks ago a month ago now right around when MVP Summit was so um you know we still have a plenty of layers to go but the good news is it does a lot of this copy paste control finds replace things for you which is very good um it also will look at your nougat packages and make sure that those things get moved over as appropriate so those are the tools you need um we have okay two and a half minutes left which is good because I wanted to leave front time for questions first I want to put up this slide so it's the marketplace for the Upgrade Assistant if you were on a Mac you can use the command line Upgrade Assistant tool we don't have anything in visual studio for Mac right now just because this was a visual Studio for Windows extension that's where it started um we are evaluating whether putting it on Mac might be useful but for now the command line will have what you want and as Olia demoed the command line is getting up to date with the latest migration stuff that I showed and then we also made this mailing list that goes to just the PMS on the Maui team called Maui Dash upgrades and what we would love for you to share with us is you know your stories your trials your tribulations any major questions blockers um keep the hate notes to a minimum thank you like Jen just try to be nice you can at least put an exclamation point I don't know um but we're really eager to hear about what's going on the more we've gotten to talk to customers who have successfully migrated or in kind of in the throes of migrating the more we've realized just how different everybody's apps are and we're trying to kind of create these patterns so we can have the tool do more um consistent things across all the different projects thank you
Info
Channel: Microsoft Developer
Views: 7,672
Rating: undefined out of 5
Keywords: .NET, .NET MAUI, C#
Id: zRR0isR0vCE
Channel Id: undefined
Length: 13min 32sec (812 seconds)
Published: Wed Jul 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.