In this tutorial, you'll learn how to create and run your first .NET Multi-platform App UI (.NET MAUI) app in Visual Studio 2022 on Windows or Visual Studio Code on Windows, macOS, or Linux. This will help to ensure that your development environment is correctly set up.
Visual Studio 2022 17.12 or greater, with the .NET Multi-platform App UI workload installed. For more information, see Installation.
Create an app
In this tutorial, you'll create your first .NET MAUI app in Visual Studio 2022 and run it on an Android emulator:
Developing .NET MAUI apps for iOS on Windows requires a Mac build host. If you don't specifically need to target iOS and don't have a Mac, consider getting started with Android or Windows instead.
In this tutorial, you'll create your first .NET MAUI app in Visual Studio and run it on an iOS simulator:
In this tutorial, you'll create your first .NET MAUI app in Visual Studio 2022 and run it on Windows:
Launch Visual Studio 2022. In the start window, click Create a new project to create a new project:
In the Create a new project window, select MAUI in the All project types drop-down, select the .NET MAUI App template, and click the Next button:
In the Configure your new project window, name your project, choose a suitable location for it, and click the Next button:
In the Additional information window, choose the version of .NET that you'd like to target and click the Create button:
Wait for the project to be created and its dependencies to be restored:
In the Visual Studio toolbar, use the Debug Target drop-down to select Android Emulators and then the Android Emulator entry:
In the Visual Studio toolbar, press the Android Emulator button:
Visual Studio will start the process of installing the default Android SDK and Android Emulator.
In the Android SDK - License Agreement window, press the Accept button:
In the User Account Control dialog, press the Yes button:
Wait for Visual Studio to download the default Android SDK and Android Emulator.
In the User Account Control dialog, press the Yes button:
In the Android SDK Platform is missing dialog, press the Install button:
In the Android SDK - License Agreement window, press the Accept button:
Wait for Visual Studio to install the Android SDK components.
In the New Device window, press the Create button:
Wait for Visual Studio to download, unzip, and create an Android emulator.
Close the Android Device Manager window:
In the Visual Studio toolbar, press the Pixel 7 - API 35 (Android 15.0 - API 35) button:
In the Android SDK - License Agreement window, press the Accept button:
In the User Account Control dialog, press the Yes button:
Wait for Visual Studio to install to download the Android SDK.
In the Visual Studio toolbar, press the Pixel 7 - API 35 (Android 15.0 - API 35) button to build and run the app:
Visual Studio will start the Android emulator, build the app, and deploy the app to the emulator.
In the running app in the Android emulator, press the Click me button several times and observe that the count of the number of button clicks is incremented.
In the Visual Studio toolbar, use the Debug Target drop-down to select iOS Simulators and then a specific iOS simulator:
In the Visual Studio toolbar, press the Start button for your chosen iOS simulator to build and run your app:
Visual Studio will build the app, start the remote iOS Simulator for Windows, and deploy the app to the remote simulator. For more information about the remote iOS Simulator for Windows, see Remote iOS Simulator for Windows.
In the running app, press the Click me button several times and observe that the count of the number of button clicks is incremented.
In this tutorial, you'll create your first .NET MAUI app in Visual Studio Code and run it on an Android emulator:
In this tutorial, you'll create your first .NET MAUI app in Visual Studio Code on a Mac, and run it on an iOS simulator:
In this tutorial, you'll create your first .NET MAUI app in Visual Studio Code on a Mac, and run it on macOS:
In this tutorial, you'll create your first .NET MAUI app in Visual Studio Code on Windows, and run it on Windows:
Launch Visual Studio Code. In the Explorer, press Create .NET Project:
Alternatively, press CTRL+SHIFT+P on Windows, or CMD+SHIFT+P on macOS, and then the .NET: New Project... command.
In the command palette, select the .NET MAUI App template:
In the Project Location dialog, select the location where you'd like the new project to be created.
Important
Projects must be created in an empty folder.
In the command palette, enter a name for your new project and press ENTER:
In the command palette, press Create project:
Wait for the project to be created, accepting the folder as a trusted location if required.
In the Explorer, expand the root node of your project and then open a C# file such as MainPage.xaml.cs:
In Visual Studio Code, verify that your Android environment is configured correctly by pressing CTRL+SHIFT+P on Windows, or CMD+SHIFT+P on macOS, and then selecting .NET MAUI: Configure Android, followed by Refresh Android environment. Any detected errors must be addressed.
In the status bar at the bottom of Visual Studio Code, press on the curly brackets symbol { } and ensure that the Debug Target is set to a specific Android emulator:
You can also set the debug target by pressing CTRL+SHIFT+P on Windows, or CMD+SHIFT+P on macOS, and selecting .NET MAUI: Pick Android Device from the command palette.
Build and run the app on Android by pressing F5 or by pressing the Run button in the upper right corner of Visual Studio Code:
If you're asked to select a debugger in the command palette, select C# and then the launch configuration for your project.
In the running app in your chosen Android emulator, press the Click me button several times and observe that the count of the number of button clicks is incremented:
Plug your device into your machine and select it as a debug target in Visual Studio Code.
Run the app.
In Visual Studio Code, verify that your Apple environment is configured correctly by pressing CMD+SHIFT+P and then selecting .NET MAUI: Configure Apple, followed by Refresh Apple environment. Any detected errors must be addressed.
In the status bar at the bottom of Visual Studio Code, press on the curly brackets symbol { } and ensure that the Debug Target is set to a specific iOS simulator:
You can also set the debug target by pressing CMD+SHIFT+P and selecting .NET MAUI: Pick iOS Device from the command palette.
Build and run the app on iOS by pressing F5 or by pressing the Run button in the upper right corner of Visual Studio Code:
If you're asked to select a debugger in the command palette, select C# and then the launch configuration for your project.
In the running app in your chosen iOS simulator, press the Click me button several times and observe that the count of the number of button clicks is incremented:
Debug the app on an iOS device
To debug the app on an iOS device:
Ensure that you've added your Apple ID to Xcode in Xcode > Settings > Accounts.
Ensure that your device has been registered with your team, if you belong to the Apple Developer Program.
Enable Developer Mode on your device. The first time you run your app you may receive a pop-up on the device - ensure you select Allow. For more information about Developer Mode, see Enabling Developer Mode on a device on developer.apple.com.
Plug your device into your machine and select it as a debug target in Visual Studio Code.
Run the app.
In Visual Studio Code, verify that your Apple environment is configured correctly by pressing CMD+SHIFT+P and then selecting .NET MAUI: Configure Apple, followed by Refresh Apple environment. Any detected errors must be addressed.
In the status bar at the bottom of Visual Studio Code, press on the curly brackets symbol { } and ensure that the Debug Target is set to your Mac:
You can also set the debug target by pressing CMD+SHIFT+P and selecting .NET MAUI: Pick macOS Device from the command palette.
Build and run the app on macOS by pressing F5 or by pressing the Run button in the upper right corner of Visual Studio Code:
If you're asked to select a debugger in the command palette, select C# and then the launch configuration for your project.
In the running app, press the Click me button several times and observe that the count of the number of button clicks is incremented:
In the status bar at the bottom of Visual Studio Code, press on the curly brackets symbol { } and ensure that the Debug Target is set to Windows:
You can also set the debug target by pressing CTRL+SHIFT+P and selecting .NET MAUI: Pick Windows Device from the command palette.
Build and run the app on Windows by pressing F5 or by pressing the Run button in the upper right corner of Visual Studio Code:
If you're asked to select a debugger in the command palette, select C# and then the launch configuration for your project.
In the running app, press the Click me button several times and observe that the count of the number of button clicks is incremented:
Troubleshooting
If your app fails to build and deploy, review Troubleshooting known issues, which may have a solution to your problem.
Next steps
In this tutorial, you've learned how to create and run your first .NET Multi-platform App UI (.NET MAUI) app.
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.