Avalonia UI is a cross-platform UI framework available for Dotnet Core. It is a project part of the .Net Foundation. Its main appeal is to provide the ability to create desktop applications for Windows, Linux and MacOS with a single code base.
In this tutorial we will see how to install the Avalonia templates and create a blank application.
Installing templates
The first thing we need to do is installing the Avalonia Templates so the dotnet new command could use them when creating new applications.
You need to go to the following Github Repository Avalonia Templates for dotnet new and download the zip version. Alternatively, you could clone it to your machine if you have git installed.
After you have unzipped the file in the location you prefer. It is needed to run the following command. Keep in mind the path you need to use is the route to the unzipped templates
dotnet new --install [path-to-templates-folder]
Tip: An easy way to add the folder path to the command line is to drag and drop the folder from the File Explorer
Creating an Avalonia application
The command executed on the previous step adds a few more templates to the dotnet new
command.
There are two project templates added are the following:
- avalonia.app: To create a barebones Avalonia application
- avalonia.mvvm: To create an application that uses the Model-View-ViewModel pattern with ReactiveUI
To create a new application you need to run the following command:
dotnet new avalonia.app -o MyApp
Where MyApp
is the name of the application we are creating.
Running the application
To run the application you need to get into the MyApp folder
cd MyApp
and then run the app with the dotnet CLI
dotnet run
The result will be the following as a blank app shows on screen.
I hope you find this useful. In following entries we will continue exploring the Avalonia UI framework.
Top comments (8)
On xubuntu 20.1
i am getting from dotnet run:::
Unhandled exception. System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory
what i am doing wrong ?
This solves the issue for me
Source
Are you able to run any other dotnet app console/web? It might be due to XFCE too, maybe a library is missing.
yes after so much google i narrowed down my problem to this
github.com/mono/SkiaSharp/issues/1050
but none of the solutions helped me
for anyone in future who run into the same problem this stackoverflow answer may help
stackoverflow.com/questions/685828...
Thx, but:
How build release version?
What final size of release version this simple app?
What contain directory of release version?
Simplicity of building and final size very crucial for cross-platform development, to compete w/ others solutions likes Electron and Flutter
How install
dotnet
on Ubuntu 22?apt install dotnet-host
?On the step dotnet new --install [path-to-templates-folder] :
Segmantation fault (Core dumped)