How to target specific frameworks when building .Net MAUI app?
13:36 25 Oct 2022

I am new to .Net Maui. I have a lot of experience with Xamarin. I am using Rider for MacOS.

I am attempting to build a .Net MAUI Application for iOS and Android. I've successfully created a .Net Maui template (from Rider). Since Android is easier to build and deploy, I want to start there. However, when I created a new MAUI template and clicked "Run" in my IDE, I got a bunch of iOS and MacOS specific errors. Through much weeping and gnashing of teeth, I discovered that this was because my project's TargetFrameworks were set in the MyApp.csproj file like so:

net6.0-android;net6.0-ios;net6.0-maccatalyst

I discovered that removing all target frameworks (below) except for net6.0-android resulted in the successful build and deployment of the MAUI app! Hooray!

net6.0-android

The problem with this solution is that I now can't build my MAUI app for iOS or MacOS. Is there a way to say:

1. If the user is trying to build an android app => TargetFramework = net6.0-android
2. If the user is trying to build an iOS app => TargetFramework = net6.0-ios
3. etc.

In other words: "I'm only trying to build Android right now. Don't worry about compiling things for any other platform / framework. I may want to build for a different platform / framework later! Just not right now"

.net-6.0 maui