Getting Started with .NET MAUI
Welcome to your first .NET MAUI application! This guide will walk you through the essential steps to create, build, and run a simple .NET MAUI app.
Prerequisites
Before you begin, ensure you have the following installed:
- .NET SDK (latest stable version recommended)
- Visual Studio (Windows) or Visual Studio for Mac (macOS) with the .NET MAUI workload.
Creating Your First .NET MAUI App
You can create a new .NET MAUI project using either Visual Studio or the .NET CLI.
Using Visual Studio
- Open Visual Studio.
- Select "Create a new project".
- Search for ".NET MAUI App" and select the template.
- Click "Next".
- Enter a project name (e.g., "MyFirstMauiApp") and a location.
- Click "Create".
Using the .NET CLI
Open your terminal or command prompt, navigate to the directory where you want to create your project, and run the following command:
dotnet new maui -n MyFirstMauiApp
This command creates a new directory named "MyFirstMauiApp" containing your project files.
Understanding the Project Structure
Once your project is created, you'll see a standard .NET project structure. Key folders include:
- Platforms: Contains platform-specific projects (iOS, Android, Windows, macOS).
- Resources: Holds app resources like images, fonts, and styles.
- App.xaml / App.xaml.cs: The entry point of your application.
- AppShell.xaml / AppShell.xaml.cs: Defines the overall structure and navigation of your app.
- MainPage.xaml / MainPage.xaml.cs: The main content page of your application.
Running Your App
To see your app in action, you need to build and deploy it to a simulator or a physical device.
On Windows (Visual Studio)
- Select a target framework (e.g., "Windows Machine") from the dropdown in the Visual Studio toolbar.
- Click the "Start" button (or press F5).
On macOS (Visual Studio for Mac)
- Select a target platform (e.g., "Mac Catalyst" or an iOS simulator) from the dropdown.
- Click the "Run" button (or press Cmd+R).
Using the .NET CLI
Navigate to your project directory in the terminal and use the following commands:
cd MyFirstMauiApp
dotnet build -t:Run -f net7.0-android
Replace net7.0-android
with your desired target framework (e.g., net7.0-ios
, net7.0-maccatalyst
, net7.0-windows
).

Your First Code Modification
Let's make a small change to the main page.
- Open
MainPage.xaml
in your editor. - Locate the
<Label>
element. - Change the
Text
attribute from "Hello, World!" to "Hello, MAUI!".
<Label Text="Hello, MAUI!" ... />
Save the file and rebuild your application. You should now see "Hello, MAUI!" displayed on the screen.
Next Steps
Congratulations! You've successfully created and run your first .NET MAUI application. Continue exploring by learning about: