.NET MAUI has been GA for all of 46 days, and we are already craving new releases; especially bug fixes. Since .NET MAUI ships as an optional workload of .NET itself, you cannot simply download a NuGet package to your local system and reference that.
You might think there would be a nightly feed to obtain .NET MAUI releases, or to be able to download artifacts directly from GitHub.com. That's not the case, but the answer is almost as simple.
I have been using the
dotnet workload install maui command as specified in the contributor development guide at dotnet/maui. This along has worked well until...it didn't. I found I often installed and uninstalled myself into a mess.
Let's look at how you can easily use the very latest commits to dotnet/maui in your local development.
Here's what I've been doing for a few days now at the advice of Shane Neuville from the .NET MAUI engineering team, and it has been working really well. This is very close to what is written in the development guide for contributors today, but I thought distilling it here might be helpful.
- Clone dotnet/maui and checkout the branch I want to use.
In most cases this will be
net6.0 for me, since
main branch is now .NET 7 and I'm not quite ready for that yet.
$ git clone firstname.lastname@example.org:dotnet/maui.git
$ git checkout net6.0
- Restore dotnet tools.
Prerequisite: make sure you're on the correct version of .NET. At the time of this writing I'm using
6.0.400-preview.22330.6. The development guide for dotnet/maui may provide details on the version alignment if you need pointers.
You need cake so you can run the scripts to build and pack the workload artifacts.
$ dotnet tool restore
- Run the cake script
Navigate to the maui folder and run the command:
$ dotnet cake --target=VS --pack
Upon completion you should see a report such as:
Task Duration -------------------------------------------------- Clean Skipped dotnet 00:00:02.1838200 dotnet-buildtasks 00:00:49.1258432 dotnet-pack-maui 00:00:25.5596615 dotnet-pack-additional 00:00:12.1436858 dotnet-pack-library-packs 00:00:11.1900158 dotnet-pack-docs 00:00:05.8721475 VS 00:00:00.3401180 -------------------------------------------------- Total: 00:01:46.4153762
The newly generated packages are now in the
maui source folder and environment variables have been configured so that Visual Studio will now use and prefer those workloads. Look at the script output for specific locations.
Visual Studio should open once the script succeeds, and now any .NET MAUI project you open will use the newly generated package from source.
As usual, clean and delete the bin/obj folders of your solution if you ever doubt that you have the latest code. Also, a close and reopen Visual Studio between rebuilds of .NET MAUI source is probably wise to make sure your solution grabs and restores the latest packages.
I was recently testing a fix from a pull request (PR), and this method made that super easy. First, I checked out the PR locally just like a branch. I then did the build step above and tested my app as usual.
To checkout a PR, I found it easiest to use the GitHub CLI. I installed it on my Mac using Brew.
$ brew install gh
And then from GitHub.com I just copied the CLI command to checkout the PR locally.
$ gh pr checkout 8605
That's it. What tips do you have to help developers and contributors be successful with .NET MAUI?