Run Your .NET MAUI App
This guide walks you through the process of building and running your first .NET Multi-platform App UI (.NET MAUI) application on your local development machine.
Prerequisites
Before you begin, ensure you have the following installed:
- .NET SDK (latest stable version)
- Visual Studio 2022 (with the .NET MAUI workload installed) or Visual Studio Code with the C# Dev Kit and .NET MAUI extension.
- An active internet connection for downloading dependencies.
Important: If you haven't already, please follow the installation guide to set up your development environment.
Building and Running the App
Once your environment is set up, you can build and run your application. We'll use the default "Hello, MAUI" project as an example.
Using Visual Studio
- Open your MAUI project in Visual Studio.
- Select the target platform from the toolbar dropdown (e.g., Windows Machine, Android Emulator, iOS Simulator).
- Click the "Start Debugging" button (the green play icon) or press F5.
Using the .NET CLI
You can also build and run your app from the command line.
- Open a terminal or command prompt.
- Navigate to your project directory:
cd path/to/your/maui/project
- Build the project:
(Replacedotnet build -t:Run -f net8.0-windows10.0.19041.0
net8.0-windows10.0.19041.0
with your target framework, e.g.,net8.0-android
,net8.0-ios
,net8.0-maccatalyst
.) - To run on a specific platform using the CLI, you'll typically use commands like:
- Windows: The
dotnet build
command above often launches the app. Alternatively, you can navigate to the output directory and run the executable. - Android: Ensure an emulator is running or a device is connected, then use:
dotnet build -t:Run -f net8.0-android
- iOS/Mac Catalyst: Requires specific configurations and Xcode on macOS.
dotnet build -t:Run -f net8.0-ios
dotnet build -t:Run -f net8.0-maccatalyst
- Windows: The
Platform-Specific Considerations
Running your .NET MAUI app involves different steps and considerations depending on the target platform:
- Windows: Builds as a standard Windows application.
- Android: Requires an Android emulator or a physical Android device.
- iOS: Requires a Mac with Xcode installed to build and run on a simulator or physical device.
- macOS: Builds as a native macOS application using Mac Catalyst.
- Tizen: Requires specific SDKs and configurations for Samsung devices.
Congratulations! You've successfully built and run your first .NET MAUI application. Explore the project structure, make some changes, and see them reflected in your running app.