mauivisual-studio-mac-2022

Error compiling MAUI project - missing MonoAOTCompiler.Task


I'm creating a MAUI application targeting iOS and Android. I have been using Visual Studio 2022 for Mac version 17.3. That version doesn't really support archiving the app, so I installed version 17.4 preview 2.1. When I try to compile my app I get the following error:

Unable to find Microsoft.NET.Runtime.MonoAOTCompiler.Task

I found a post that indicated I should run the command: dotnet add package Microsoft.NET.Runtime.MonoAOTCompiler.Task --version 7.0.0-rc.2.22472.3

When I run that command in terminal I get the error: error: Value cannot be null. (Parameter 'version')

Everything I have found indicated that the problem should have been fixed in Preview 2.1 of Visual Studio 2022 for Mac, but it is still occurring.

Can anyone help me resolve this? I need to publish my app to the stores and can't get it to compile in release mode or create the archive because of that.


Solution

  • You need to add the package to your project.

    First, you should right click your project name and choose the Manage Nuget packages button.

    enter image description here

    Second, you can search the package Microsoft.NET.Runtime.MonoAOTCompiler.Task and install it. enter image description here

    Then you successfully add the package to your project.