Table of Contents
Introduction to .NET MAUI Deployment
.NET MAUI (Multi-platform App UI) enables you to build native applications for Android, iOS, macOS, and Windows from a single, shared C# codebase. This document provides a comprehensive guide to deploying your .NET MAUI applications across various target platforms.
Note: Deployment procedures can vary significantly based on the target platform, your development environment, and distribution methods.
Android Deployment
Deploying your .NET MAUI app to Android involves creating an APK (Android Package) or an App Bundle for distribution.
Prerequisites
- Android SDK and build tools installed.
- An Android emulator or physical device configured for development.
Steps
- Configure Project Properties: In Visual Studio, right-click on your Android project and select "Properties". Configure settings like package name, version, and target frameworks.
- Build for Release: Select "Release" configuration and "Android" as the target platform.
- Create APK or App Bundle:
- For an APK: Navigate to
Build > Publish Android App
in Visual Studio. Follow the wizard to configure signing keys and distribution channels (e.g., Google Play Store). - For an App Bundle: Use the
dotnet publish -f net6.0-android -c Release
command in the terminal, or use Visual Studio's publish options. App Bundles are recommended for Google Play.
- For an APK: Navigate to
- Signing: Ensure your application is signed with a release key to be deployable to app stores.
You can also deploy to an emulator or device directly from Visual Studio by selecting the appropriate target.
Refer to the official Android Deployment Guide for detailed instructions.
Android
Build and deploy your MAUI application to Android devices and the Google Play Store.
iOS Deployment
Deploying .NET MAUI applications to iOS requires a macOS machine with Xcode installed. You can deploy to simulators or physical devices.
Prerequisites
- A macOS machine.
- Xcode installed.
- Apple Developer account (for distribution to the App Store).
Steps
- Configure Project Properties: In Visual Studio for Mac or Visual Studio (connected to a Mac), right-click on the iOS project and configure settings like bundle identifier and deployment target.
- Build for Release: Select "Release" configuration and "iOS" as the target platform.
- Archive and Distribute:
- In Visual Studio for Mac, go to
Build > Archive For Publishing
. - This will create an archive that can be deployed to test devices or submitted to the App Store via Xcode's Organizer.
- In Visual Studio for Mac, go to
- Signing: Ensure your app is signed with the correct provisioning profiles and certificates.
For detailed information, consult the iOS Deployment Guide.
iOS
Deploy your MAUI application to iPhones and iPads, targeting the Apple App Store.
Windows Deployment
Deploying .NET MAUI applications to Windows can be done using MSIX packages or direct executables.
Prerequisites
- Windows 10 version 1903 or later.
- Visual Studio with the ".NET Desktop Development" workload.
Steps
- Configure Project Properties: In your Windows project properties, set up package information.
- Build for Release: Select "Release" configuration and "Windows" (or "WinUI") as the target platform.
- Create MSIX Package:
- Right-click the Windows project and select
Publish > Create App Packages
. - Choose "Sideloading" for manual installation or "Microsoft Store" for distribution via the Microsoft Store.
- Follow the wizard to generate the MSIX package.
- Right-click the Windows project and select
- Direct Executable: For simpler deployment, you can publish directly as an executable. Use the command:
dotnet publish -f net6.0-windows10.0.19041 -c Release -p:WindowsPackageType=None
For more details, see the Windows Deployment Guide.
Windows
Package and deploy your .NET MAUI application for Windows 10 and Windows 11.
macOS Deployment
Deploying .NET MAUI apps to macOS involves creating a `.app` bundle, typically for distribution via the Mac App Store or direct download.
Prerequisites
- A macOS machine.
- Xcode installed.
- Apple Developer account for App Store distribution.
Steps
- Configure Project Properties: Set up the macOS project's bundle identifier and other relevant settings.
- Build for Release: Select "Release" configuration and "Mac Catalyst" (for cross-platform) or "macOS" as the target.
- Create .app Bundle:
- Use the command
dotnet publish -f net6.0-maccatalyst -c Release
ordotnet publish -f net6.0-macos -c Release
. - Visual Studio for Mac provides archiving and distribution options similar to iOS.
- Use the command
- Code Signing: Essential for macOS deployment, especially for App Store submission.
Learn more in the macOS Deployment Guide.
macOS
Package your .NET MAUI application for macOS, including distribution through the Mac App Store.
Linux Deployment
.NET MAUI currently has experimental support for Linux. Deployment typically involves building a self-contained application that can be run on Linux environments.
Prerequisites
- A Linux development environment or a Windows machine with a Linux VM.
- The .NET SDK for Linux.
Steps
- Build for Release: Use the .NET CLI:
dotnet publish -f net6.0-linux -c Release
. - Runtime Identifiers (RIDs): Specify the correct RID for your target Linux distribution (e.g.,
-r linux-x64
). - Dependencies: Ensure all necessary runtime dependencies are available on the target Linux machine.
Note: Linux support is still evolving. Check the latest documentation for current capabilities.
See the Linux Deployment Guidance for updates.
Linux
Experimental support for deploying .NET MAUI applications to Linux distributions.
Web Deployment
While .NET MAUI is primarily for native applications, Blazor Hybrid can be used to embed Blazor Web components within native apps. For full web deployment, consider using Blazor WebAssembly or Blazor Server.
This section focuses on deploying the native MAUI applications.
Web
This section covers native app deployment. For web-specific technologies, refer to Blazor documentation.
Packaging Options
Beyond platform-specific deployment, .NET MAUI offers flexible packaging options:
- MSIX: A modern Windows app package format offering reliable installation, uninstallation, and updates.
- App Bundles (Android): Optimized for Google Play, delivering smaller downloads tailored to device configurations.
- IPA (iOS): The standard archive format for iOS apps, used for TestFlight and App Store submission.
- DMG / PKG (macOS): Standard installers for macOS applications.
- Self-Contained Deployments: Publishing the application with its own .NET runtime, making it runnable without pre-installed .NET on the target machine.
Next Steps
After successfully deploying your .NET MAUI application, consider the following:
- App Store Submission: Familiarize yourself with the guidelines and processes for the Google Play Store, Apple App Store, and Microsoft Store.
- CI/CD Integration: Automate your build, test, and deployment pipelines using tools like Azure DevOps, GitHub Actions, or Jenkins.
- Performance Monitoring: Implement tools to track your app's performance and identify potential issues in production.
- Updates and Maintenance: Plan for regular updates to address bugs, introduce new features, and maintain compatibility with the latest OS versions.
Important: Always refer to the official documentation for the most up-to-date information and specific commands for each platform.