This is not a specific answer to your question but here is what worked for me for most of the time.
- Ensure NuGet packages are updated for the project (noting that there are subtle cases of workarounds where the latest packages may not work with Maui, but there are exceptions).
- Delete the obj and bin folders in your project folder. You may need to exit Visual Studio as files in the bin folder may be locked and won't allow deleting the folder.
- In the project folder, launch the Cmd Prompt with elevated privilege (as Administrator).
- Run the command
dotnet restore --no-cache
Now go to Visual Studio and rebuild your project. Hope it compiles this time. This is my starting point when compilations fail. Good luck.