DEV Community

Cover image for Avalonia UI on Ubuntu: Getting Started
Carlos Fabara
Carlos Fabara

Posted on • Updated on

Avalonia UI on Ubuntu: Getting Started

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.

Avalonia templates Github Repo

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]
Enter fullscreen mode Exit fullscreen mode

Tip: An easy way to add the folder path to the command line is to drag and drop the folder from the File Explorer

Drag and drop folder to the terminal

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

and then run the app with the dotnet CLI

dotnet run
Enter fullscreen mode Exit fullscreen mode

The result will be the following as a blank app shows on screen.

Blank Avalonia App

I hope you find this useful. In following entries we will continue exploring the Avalonia UI framework.

Discussion (4)

Collapse
thelordchosen profile image
Thelordchosen

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 ?

Collapse
carlos487 profile image
Carlos Fabara Author

Are you able to run any other dotnet app console/web? It might be due to XFCE too, maybe a library is missing.

Collapse
thelordchosen profile image
Thelordchosen

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

Thread Thread
thelordchosen profile image
Thelordchosen

for anyone in future who run into the same problem this stackoverflow answer may help

stackoverflow.com/questions/685828...