Get Started with .NET MAUI

.NET Multi-platform App UI (.NET MAUI) is an open-source framework for creating native cross-platform applications for iOS, Android, macOS, and Windows from a single C# codebase.

This guide will walk you through the essential steps to set up your development environment and create your first .NET MAUI application.

Step 1: Install .NET MAUI

To develop .NET MAUI apps, you need the .NET SDK and the .NET MAUI workload. You can install these using the Visual Studio Installer or the .NET CLI.

Using Visual Studio Installer:

  1. Download and install the latest version of Visual Studio.
  2. During installation, select the ".NET MAUI development" workload.

Using .NET CLI:

dotnet workload install maui

Step 2: Create a New .NET MAUI Project

You can create a new project using Visual Studio or the .NET CLI.

Using Visual Studio:

  1. Open Visual Studio.
  2. Click "Create a new project".
  3. Search for ".NET MAUI App" and select the template.
  4. Click "Next", provide a project name and location, and then click "Create".

Using .NET CLI:

dotnet new maui -n MyMauiApp
cd MyMauiApp
Visual Studio Template Selection (Mockup)

Step 3: Explore the Project Structure

A typical .NET MAUI project includes the following key folders:

  • Platforms: Contains platform-specific code.
  • Resources: Holds images, fonts, and app icons.
  • App.xaml and App.xaml.cs: The entry point of your application.
  • AppShell.xaml and AppShell.xaml.cs: Defines the application's shell or navigation structure.
  • MainPage.xaml and MainPage.xaml.cs: The main UI page of your application.
Important: Ensure your development environment is configured with the correct SDKs and build tools for the target platforms you intend to deploy to.

Step 4: Run Your First App

You can run your application on an emulator, simulator, or a physical device.

Using Visual Studio:

  1. Select your target platform (iOS, Android, Windows, macOS) from the debugger dropdown.
  2. Click the "Start" button (green play icon) to build and deploy your app.

Using .NET CLI:

dotnet build -t:Run -f net7.0-android  // For Android
dotnet build -t:Run -f net7.0-ios      // For iOS
dotnet build -t:Run -f net7.0-maccatalyst // For macOS
dotnet run -f net7.0-windows           // For Windows
Running App on an Android Emulator (Mockup)

What's Next?

Now that you have successfully created and run your first .NET MAUI app, you can start building more complex UIs, implementing data binding, and exploring the rich set of controls available in .NET MAUI.