Check out Airport Guides and Baseball Odds for iOS and Android*!
I don’t remember exactly why I embarked on the project to upgrade my apps to use .NET 8 from .NET 6. It is true that .NET 6 is pretty old at this point, and I think Microsoft has dropped support for it, so…maybe that’s why? But I suspect .NET 6 can’t target newer versions of iOS/Android, and either Apple or Google is requiring that for app updates.
Anyway, after porting them from Xamarin.Forms to MAUI just over a year ago, my hope was that I was on the happy path and upgrading would be easy. There’s even a handy guide for upgrading from .NET 6 to 7 and from .NET 7 to 8!
Sadly, no. Here is roughly what happened in chronological order:
- At some point, I ignored the upgrade guide and used a hard coded version of
Microsoft.Maui.Controls
instead of the$(MauiVersion)
that the upgrade guide from .NET 7 to 8 told me to do. I don’t know why I did this, but things broke in surprisingly weird ways. - Somehow
ImplicitUsings
stopped working so every single code file was broken and I had to add a bunch ofusing
statements. Annoying but reasonably easy to fix once I figured out what was going on. (it helps that these apps are fairly small) - I got a bunch of errors about invalid paths for images – I tried removing some duplicate images that weren’t used but still had a few of these. I tried some of the suggestions in this GitHub issue and this documentation to no avail.
- At some point I had the bright idea to create an entirely new .NET MAUI 8 app and look at what it was doing in its .csproj file. This gave me a pointer to adding
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
which helped with some problems. - Out of desperation, I started to delete the
bin/
andobj/
directories after trying stuff instead of just doing a clean build, and frustratingly this helped with some problems. This meant that trying stuff out took even longer because I’d have to do this all the time 🙄
I got stuck here for a while and was feeling despair about all this. It seems like every few years I have to rewrite these dang apps to use the newest app framework (see a history here), and I don’t have a lot of free time or energy.
But taking a break gave me an idea about a new approach. I decided to:
- Make a new .NET MAUI 8 project from a template
- Ensure that it builds (it did!)
- Add the handful of NuGets that I use
- Ensure that it still builds (it did!!)
- Instead of copying all my code into this new project, look carefully at the resulting .csproj and make my existing .csproj match as closely as possible
And this worked shockingly well! For what it’s worth, a lot of what I changed was getting rid of Compile
, DependentUpon
, and MauiXaml
tags – I guess these are mostly implicit now?
I did hit a few more gotchas. One was this error when building Android:
1>C:\Users\greg\.nuget\packages\xamarin.build.download\0.11.0\buildTransitive\Xamarin.Build.Download.targets(60,4): error MSB4064: The “AndroidFixManifests” parameter is not supported by the “XamarinDownloadArchives” task loaded from assembly: Xamarin.Build.Download, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null from the path: C:\Users\greg\.nuget\packages\xamarin.build.download\0.11.4\buildTransitive\Xamarin.Build.Download.dll. Verify that the parameter exists on the task, the <UsingTask> points to the correct assembly, and it is a settable public instance property.
1>C:\Users\greg\.nuget\packages\xamarin.build.download\0.11.0\buildTransitive\Xamarin.Build.Download.targets(52,3): error MSB4063: The “XamarinDownloadArchives” task could not be initialized with its input parameters.
This is one of the errors that deleting the bin/
and obj/
directories would usually fix. Later I upgraded this NuGet to 0.11.4 and I think that made this go away for good, as per this Stack Overflow post.
Another problem was Could not find workload 'ios' extended by workload 'maui-ios' in manifest 'microsoft.net.sdk.maui'
which I could fix with the tips on this GitHub issue.
Once I got to the point of building the iOS app, I quickly discovered that the Mac Mini I had (from 2016) was too old to install the needed version of Xcode. I knew this day was coming eventually, as the Mac Mini predated the switch to ARM, and was also painfully slow, so I bought an Mac Mini M1 off of eBay. And it is so much faster than the old one! And it seems like some of the more annoying issues have gone away.
The last problem I ran into was that the app would crash on launch in some Admob ads code. The packages I had been using for Admob stuff dated back to the Xamarin days and I wasn’t sure if they were expected to work or what. And debugging that stuff is especially painful. I slowly convinced myself that spending a bit of money on the MtAdmob plugin for MAUI was worth it, and when I downloaded the free version and it worked on the first try I was sold. All told I spent more money than I had hoped, but the apps do all right and should pay for both of those purchases in six months or so.
So now my apps are fully up to date, and maybe I’ll spend a little time actually improving them instead of fighting with app frameworks! (although apparently Apple has a privacy manifest that I need to be using to make any updates past May 1st? sigh…)
* technically Airport Guides for Android isn’t live yet, but it hopefully will be in a day or so, and I’m writing this now to get some catharsis!