Build your first app

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 17.3 Preview on Windows.

Important

Visual Studio support for .NET Multi-platform App UI (.NET MAUI) is currently in preview. This content relates to a pre-release product that may be substantially modified before it's released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Developing .NET MAUI apps for iOS 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.

Visual Studio for Mac support will arrive in a future release.

Get started with Visual Studio 2022 17.3 (Preview)

In this tutorial, you'll create your first .NET MAUI app in Visual Studio 2022 17.3 Preview, and run it on an Android emulator:

  1. To create .NET MAUI apps, you'll need the latest Visual Studio 2022 17.3 Preview:

    Download Visual Studio 2022 Community Preview

    Download Visual Studio 2022 Professional Preview

    Download Visual Studio 2022 Enterprise Preview

    Either install Visual Studio, or modify your installation, and install the .NET Multi-platform App UI development workload with its default optional installation options:

    Visual Studio workloads for .NET MAUI.

In this tutorial, you'll create your first .NET MAUI app in Visual Studio 17.3 Preview, and run it on an iOS simulator:

  1. To create .NET MAUI apps, you'll need the latest Visual Studio 2022 17.3 Preview:

    Download Visual Studio 2022 Community Preview

    Download Visual Studio 2022 Professional Preview

    Download Visual Studio 2022 Enterprise Preview

    Either install Visual Studio, or modify your installation, and install the .NET Multi-platform App UI development workload with its default optional installation options:

    Visual Studio workloads for .NET MAUI.

In this tutorial, you'll create your first .NET MAUI app in Visual Studio 2022 17.3 Preview, and run it on Windows:

  1. To create .NET MAUI apps, you'll need the latest Visual Studio 2022 17.3 Preview:

    Download Visual Studio 2022 Community Preview

    Download Visual Studio 2022 Professional Preview

    Download Visual Studio 2022 Enterprise Preview

    Either install Visual Studio, or modify your installation, and install the .NET Multi-platform App UI development workload with its default optional installation options:

    Visual Studio workloads for .NET MAUI.

  1. Launch Visual Studio 2022 17.3 Preview, and in the start window click Create a new project to create a new project:

    New solution.

  2. 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:

    Choose a template.

  3. In the Configure your new project window, name your project, choose a suitable location for it, and click the Create button:

    Configure the project.

  4. Wait for the project to be created, and its dependencies to be restored:

    Restored dependencies.

  1. In the Visual Studio toolbar, use the Debug Target drop down to select Android Emulators and then the Android Emulator entry:

    Select the Android Emulator debugging target for .NET MAUI.

  2. In the Visual Studio toolbar, press the Android Emulator button:

    Android emulator button.

    Visual Studio will start to install the default Android SDK and Android Emulator.

  3. In the Android SDK - License Agreement window, press the Accept button:

    First Android SDK License Agreement window.

  4. In the Android SDK - License Agreement window, press the Accept button:

    Second Android SDK License Agreement window.

  5. In the User Account Control dialog, press the Yes button:

    Android SDK license user account control dialog.

  6. In the License Acceptance window, press the Accept button:

    Android device license window.

    Wait for Visual Studio to download the Android SDK and Android Emulator.

  7. In the Visual Studio toolbar, press the Android Emulator button:

    Android emulator button.

    Visual Studio will start to create a default Android emulator.

  8. In the User Account Control dialog, press the Yes button:

    Android Device Manager user account control dialog.

  9. In the New Device window, press the Create button:

    New Android Device window.

    Wait for Visual Studio to download, unzip, and create an Android emulator.

  10. Close the Android Device Manager window:

    Android Device Manager window.

  11. In the Visual Studio toolbar, press the Pixel 5 - API 30 (Android 11.0 - API 30) button to build and run the app:

    Pixel 5 API 30 emulator button.

    Visual Studio will start the Android emulator, build the app, and deploy the app to the emulator.

    Warning

    Hardware acceleration must be enabled to maximize Android emulator performance. Failure to do this will result in the emulator running very slowly. For more information, see How to enable hardware acceleration with Android emulators (Hyper-V & HAXM).

  12. 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.

    App running in the Android emulator.

  1. In the Visual Studio toolbar, use the Debug Target drop down to select Framework and then the net6.0-windows entry:

    Select the Windows Machine debugging target for .NET MAUI.

  2. In the Visual Studio toolbar, press the Windows Machine button to build and run the app:

    Run .NET MAUI app in Visual Studio button.

    If you've not enabled Developer Mode, Visual Studio will prompt you to enable it. In the Enable Developer Mode for Windows dialog, click settings for developers to open the Settings app:

    Enable Windows developer mode dialog.

    In the Settings app, turn on Developer Mode and accept the disclaimer:

    Developer Mode toggle on the Windows 11 settings app.

    Close the Settings app, and then close the Enable Developer Mode for Windows dialog.

  3. In the running app, press the Click me button several times and observe that the count of the number of button clicks is incremented:

    .NET MAUI app running on Windows.

  1. In Visual Studio, pair the IDE to a Mac Build host. For more information, see Pair to Mac for iOS development.

  2. In the Visual Studio toolbar, use the Debug Target drop down to select iOS Simulators and then a specific iOS simulator:

    Visual Studio iOS simulators debug targets.

  3. In the Visual Studio toolbar, press the Start button for your chosen iOS simulator to build and run your app:

    Visual Studio iOS simulator debug target choice.

    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.

  4. In the running app, press the Click me button several times and observe that the count of the number of button clicks is incremented.

    .NET MAUI app running in iOS Simulator on a Mac.

Next steps

In this tutorial, you've learnt how to create and run your first .NET Multi-platform App UI (.NET MAUI) app in Visual Studio 2022 17.3 Preview on Windows.

To learn the fundamentals of building an app with .NET MAUI, and more advanced topics such as local data storage and invoking REST-based web services, see Build mobile and desktop apps with .NET MAUI.