Setting Up Your Development Environment for .NET MAUI
This guide will walk you through the essential steps to set up your machine for developing cross-platform applications with .NET MAUI (Multi-platform App UI).
Prerequisites
Before you begin, ensure you have the following installed:
- .NET SDK: .NET MAUI requires the latest .NET SDK. You can download it from the official .NET website.
- Visual Studio: For Windows, Visual Studio 2022 or later is recommended. For macOS, Visual Studio for Mac is required.
Installing the .NET MAUI Workload
Once you have the .NET SDK installed, you need to install the .NET MAUI workload. This can be done using the .NET CLI.
For Windows:
Open your command prompt or PowerShell and run the following command:
dotnet workload install maui
For macOS:
Open your Terminal and run the following command:
dotnet workload install maui
This command downloads and installs all the necessary components for MAUI development, including build tools and SDKs for target platforms like Android, iOS, macOS, and Windows.
Configuring Visual Studio
Visual Studio 2022 (Windows)
- Launch Visual Studio Installer.
- Click Modify on your Visual Studio 2022 installation.
- In the Workloads tab, ensure that the .NET MAUI workload is selected. This workload includes the necessary components for Android and iOS development.
- If you intend to develop for iOS, you'll also need to ensure that the "Mobile development with .NET" workload is selected, which includes the Xamarin components required for MAUI's iOS support.
- Click Modify to install the selected components.
Visual Studio for Mac
- Launch Visual Studio for Mac.
- Go to Visual Studio > Check for Updates....
- In the Updates dialog, select the Updates Available tab.
- Expand the .NET MAUI section and ensure the .NET MAUI workload is selected for installation.
- Click Continue to install the workload.
Optional: Android SDK Setup
If you plan to develop for Android, you'll need the Android SDK. Visual Studio typically handles this installation for you when you select the .NET MAUI workload. However, you can also manage Android SDKs manually:
- Visual Studio (Windows): The Android SDK location can be configured in Visual Studio under Tools > Options > Xamarin > Android Settings.
- Visual Studio for Mac: Android SDKs are managed through Visual Studio for Mac > Preferences > SDK Locations > Android.
It's recommended to install at least one Android SDK platform and the corresponding build tools.
Optional: Xcode Setup (for iOS and macOS Development)
To develop and deploy .NET MAUI apps to iOS and macOS, you must have Xcode installed on a Mac. You can download Xcode from the Mac App Store.
- Ensure you have the latest stable version of Xcode installed.
- After installing Xcode, open it at least once to accept the license agreement and install any additional components.
- You can configure the Xcode location in Visual Studio for Mac under Preferences > SDK Locations > Apple SDKs.
You will need a Mac to build and debug iOS and macOS applications, even if you are primarily developing on Windows.
Creating Your First .NET MAUI App
With the setup complete, you're ready to create your first .NET MAUI application. You can do this directly from Visual Studio's project templates.
- Open Visual Studio.
- Select Create a new project.
- Search for ".NET MAUI" and select the ".NET MAUI App" template.
- Follow the prompts to name your project and choose a location.
- Select your target framework (e.g., .NET 7.0, .NET 8.0).
- Click Create.
Your new .NET MAUI project will be created, and you can now start building your cross-platform applications!