Creating Your First .NET MAUI Project
Welcome to the exciting world of .NET MAUI! In this tutorial, we'll guide you through the steps to create your very first .NET MAUI project. This project will serve as the foundation for your cross-platform application development journey.
Using Visual Studio
Visual Studio provides a streamlined experience for creating .NET MAUI applications. Follow these steps to get started:
- Open Visual Studio: Launch Visual Studio on your machine.
- Create a new project:
- Click on "Create a new project".
- In the search bar, type ".NET MAUI".
- Select the ".NET MAUI App" template and click "Next".
- Configure your project:
Figure 1: The .NET MAUI App template in Visual Studio. - Project name: Enter a descriptive name for your project, for example,
MyFirstMauiApp
. - Location: Choose a directory where you want to save your project.
- Solution name: This will typically default to your project name.
- Click "Next".
- Project name: Enter a descriptive name for your project, for example,
- Additional information:
- Select the .NET version you want to use (e.g., .NET 6.0 or later).
- Click "Create".
Visual Studio will now create your new .NET MAUI project, setting up all the necessary files and configurations.
Using the .NET CLI
For developers who prefer the command line, the .NET CLI offers a powerful way to create .NET MAUI projects.
- Open a terminal or command prompt.
- Navigate to your desired directory.
- Run the following command:
dotnet new maui -n MyFirstMauiAppCLI
This command creates a new .NET MAUI project named
MyFirstMauiAppCLI
in your current directory. - Navigate into your project directory:
cd MyFirstMauiAppCLI
Note: Ensure you have the .NET MAUI workload installed. If not, you can install it using: dotnet workload install maui
Project Structure
Once your project is created, you'll see a familiar project structure. Here are some key folders and files:
Platforms
: Contains platform-specific code and resources. You'll find subfolders forAndroid
,iOS
,MacCatalyst
, andWindows
.Resources
: Holds application resources such as images, fonts, and styles.