Updating your .NET MAUI app from .NET 6 to .NET 7 is easy! In this post we’ll see what the process looks like.
What’s New in .NET 7?
There are many enhancements for .NET MAUI in .NET 7. First, a very much anticipated feature is .NET MAUI Maps. With Maps you can add a map in your iOS, macOS and Android applications.
Additionally, a whole lot of features that are specific to the desktop went in. This of: tooltips, context menus, window sizes and positions and more.
To top all of this off, there is a continuous focus on the performance of .NET MAUI apps and .NET 7 has a lot of those performance enhancements built-in. Just by upgrading to .NET 7, your app will become faster!
There are a lot more enhancements that went in which you’ll have to discover for yourself. This blog post by David is a great starting point.
Visual Studio 2022 17.4
The easiest way to get .NET 7 and the .NET MAUI workload update is by installing Visual Studio 2022 version 17.4. This version has gone stable together with the launch of .NET 7.
If you don’t want to update, you don’t technically have to, you can also install .NET 7, just the SDK and stick with the previous Visual Studio version.
Update .NET MAUI to .NET 7
Then, updating you .NET MAUI app to .NET 7. When you have everything above set up, it should not be complicated, just follow these steps.
To update your .NET MAUI app to .NET 7 follow these steps
- Open your .NET MAUI app csproj file
You might need to unload your project by right-clicking and choose: Unload project. Or just click once on your project node in the Solution Explorer.
- Find the TargetFrameworks node(s)
These will have all the platforms that you want to target, e.g. net6.0-ios, net6.0-android. Note that these might be spread out over more than one TargetFrameworks tag.
- Replace net6.0 with net7.0
For each of the target frameworks replace net6.0 with net7.0. For example: net6.0-ios becomes net7.0-ios.
- Save the csproj file
Save the csproj file and wait until the dependencies are loaded. In Visual Studio check under the Dependencies node under your project to see the net7.0 targets there now.
That’s it! That’s the upgrade! While the process is pretty straight-forward, under the hood something big is happening. If you do run into build errors, do a clean and rebuild and maybe just to be sure delete your bin and obj folders.
There are a handful of breaking changes, so if you find a compile error in your code something might actually need updating.
Congratulations! You .NET MAUI app is now on .NET 7, enjoy all the new fixes and features and have fun developing with your .NET MAUI application!