Create and Run a Project
Install Templates
Before starting, ensure that you have installed the Avalonia templates:
dotnet new install Avalonia.Templates
Create the Project
To get started, we're going to use the MVVM Avalonia template: Avalonia MVVM Application
(or avalonia.mvvm
in the CLI).
- Command Line
- Rider
- Visual Studio
Run the command:
dotnet new avalonia.mvvm -o GetStartedApp
This will create a new folder called GetStartedApp
containing the new project.
- On the Rider startup screen, select New Solution
- In the sidebar, scroll down and select Avalonia App
- Type
GetStartedApp
in the Solution Name field - Click Create
The template will create a new solution and project.
- In Visual Studio, click Create a new project.
- Type
Avalonia
in the search box. - Click Avalonia Application then click Next.
-
Name the project
GetStartedApp
, and click Create. -
The next screen allows selecting the platforms you wish to target: click Desktop then click Next.
-
The next screen allows selecting a design pattern: click ReactiveUI then click Create.
The template will create a new solution and two new projects. GetStartedApp
is the main project that is shared between each platform. GetStartedApp.Desktop
is the platform-specific project for the desktop platform.
Run the Project
We're now ready to run the project!
- Command Line
- Rider
- Visual Studio
Go into the GetStartedApp
directory and run:
dotnet run
Press the Run button in the Rider toolbar:
Right-click on the GetStartedApp.Desktop
project and select Set as Startup Project.
Hit F5
to run the project.
The solution will build and run.
You should now be running your first Avalonia application!