If an update for Visual Studio 2022 Preview is available, an Update button will be shown. Select it to update before modifying the installation.
Find your Visual Studio 2022 Preview installation and select Modify.
Select .NET Multi-Platform App UI development.
Select the Modify button.
Create a new .NET MAUI app:
Open Visual Studio 2022 Preview.
Select the Create a new project button.
Select MAUI from the Project type drop-down.
Select the .NET MAUI App (Preview) template and select the Next button.
Enter MyFirstMauiApp as the project name and select the Create button.
Android SDK 安装
Specific versions of the Android SDK are required to build projects. If your machine is missing the required SDK, you'll see the following prompt while the new project is loading. Click Accept to have the automatic installation begin.
还原 NuGet 包
包还原过程将自动启动。请等候，直到 已还原 或 就绪 消息显示在屏幕左下角的状态栏中。
This tutorial will focus on deploying a .NET MAUI application to your local Windows machine or to an Android device or emulator. You can decide to deploy to one or more of the platforms based on your development environment.
Set up Windows for development
To develop Windows applications, you will need to enable developer mode to sideload applications on Windows 11 or Windows 10.
On Windows, go to the Settings application.
Search for Developer settings, which is located under For developers in Privacy & security on Windows 11 and Update & Security on Windows 10.
Turn on the toggle under Developer Mode.
The Use developer features dialog is displayed. Select Yes to confirm that you want to enable the developer mode.
设置 Android Emulator
If you don't have an Android device to deploy to, you can set up an Android emulator. If you've already done this, you can skip this step.
If this if your first time building a .NET MAUI application, you'll see "Android Emulator" in the debug menu. Click it to start the creation process.
This brings up a User Account Control prompt to be accepted and then the emulator creation process. The options are automatically populated for a base emulator. If required, change any options and then select Create.
此时，系统可能会提示你同意 Android Emulator 的许可协议。请阅读并选择“接受”以继续此流程。此操作会下载仿真程序映像并完成创建，以便在 Visual Studio 中使用仿真程序。
From the debug drop down menu, select net6.0-windows under Framework. Once selected, you should see Windows Machine as the debug target.
从菜单中选择“调试 > 启动调试”。
Run on Android
From the debug drop down menu, select net6.0-android under Framework.
From the menu, select Debug > Start Debugging. If this option is disabled, ensure an emulator is selected. If you don't have an emulator, select Android Emulator and you'll be guided through creating a new emulator.
应用程序将生成，之后会部署到 Android 设备/仿真器并运行。
Congratulations, you've built and run your first .NET MAUI app!
When developing applications with .NET MAUI, XAML Hot Reload is available when you're debugging your application. This means that you can change the XAML user interface (UI) while the application is running and the UI will update automatically.
In the Solution Explorer, double-click the MainPage.xaml file under the MyFirstMauiApp project.
Currently, the Text of the first Label is set to say Hello, World! as shown in the following code: