How can I remove the platforms I do not need to compile for in .net MAUI?
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.
Introduction
A .NET MAUI single-project app uses multi-targeting, which means one project can build for several platforms by listing multiple target frameworks in the project file. If you no longer need some platforms, the correct place to remove them is the .csproj file, not the Platforms folder. In practice, you reduce the TargetFrameworks list to only the platforms you actually support.
The Setting That Controls Platform Compilation
In a MAUI project, the important property is TargetFrameworks. A typical project may start with several target framework monikers, often one for Android, one for iOS, one for Mac Catalyst, and one for Windows.
If you want only Android and iOS, remove the others from that property.
That is the main change. The SDK builds only the listed targets.
Use TargetFramework for a Single Platform
If the project should build for exactly one platform, you can use a single TargetFramework instead of TargetFrameworks.
This makes the intent very explicit and can simplify local development when the app is no longer truly cross-platform.
What You Usually Do Not Need to Remove
You generally do not need to delete the platform folders immediately. MAUI's single-project model uses multi-targeting so that platform-specific folders are included only for the matching target build. That means a Platforms/iOS folder is not compiled into an Android build just because the folder exists.
In other words:
- removing the target framework stops that platform from being built
- deleting the folder is optional cleanup
- keeping the folder may still be useful if you plan to re-enable that platform later
This distinction matters because developers often remove source files first and leave the target framework untouched, which does not solve the build problem.
Conditional Platform Targets
Some MAUI project files use conditions so that a platform target is only added on a matching host operating system. For example, Windows targeting may be appended only when building on Windows.
If you no longer want Windows support, remove that conditional addition too. Otherwise the project may still target Windows on Windows machines.
Clean Up Platform-Specific References
After changing the target frameworks, review any platform-specific package references, runtime identifiers, or conditional item groups in the project file.
If the platform is gone, the condition is harmless but unnecessary. Cleaning these sections makes the project easier to maintain.
You should also review CI pipelines and publish commands. A build server may still call dotnet publish -f net9.0-windows10.0.19041.0 even after the project file has changed.
Common Pitfalls
The most common mistake is deleting the Platforms folder for a platform but forgetting to remove its target framework. The build still targets that platform because TargetFrameworks is what actually drives compilation.
Another issue is removing a platform from one TargetFrameworks entry while leaving a conditional platform append elsewhere in the file. That can make the platform seem to "come back" on certain machines.
Developers also sometimes leave platform-specific package references, signing settings, or CI steps in place after removing a platform. That creates confusing build errors later.
Finally, if you only want to stop compiling a platform temporarily, do not over-clean the project. Removing the TFM is enough. You can keep the platform code in source control until the decision is permanent.
Summary
- In .NET MAUI, platform compilation is controlled by
TargetFrameworksorTargetFrameworkin the.csprojfile. - Remove the platform TFM to stop building that platform.
- Deleting the corresponding
Platformsfolder is optional cleanup, not the main fix. - Check for conditional target-framework entries and platform-specific references.
- Update CI and publish commands so they match the reduced platform list.
Related reading
- How can I run background tasks in React Native?
- How can I run Tensorflow on one single core?
- How can I solve 'ran out of gpu memory' in TensorFlow
- How can I speed up a topic model in R?
- How can I rename a project folder from within Visual Studio?
- How can I retrieve Id of inserted entity using Entity framework?
- How can I speed up deep learning on a non-NVIDIA setup?
- How can I speed up Python's 'unittest' on multicore machines?

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.