Avalonia, ASP.NET Core, and WPF
For a long time, C# development was closely associated with Windows and Microsoft Visual Studio. However, the modern .NET ecosystem has changed the way developers work. Today, Linux can be a powerful development environment for building C# applications, including desktop applications and web applications.
As a Fedora 44 user, I decided to explore what is possible with C# and .NET 10 without leaving my Linux environment.
My goal is simple: to understand how far I can go with one programming language across three different development paths: WPF, Avalonia UI, and ASP.NET Core.
1. Preparing the Linux Development Environment
The first step was installing the .NET SDK. On Fedora, the installation was straightforward:
After installation, I verified the SDK:
The .NET SDK provides the command-line tools needed to create, build, and run .NET applications.
I also chose Visual Studio Code as my code editor, together with Microsoft's C# development tools. This setup gives me a practical environment for learning C# and experimenting with different types of applications directly on Linux.
2. Desktop Applications with Avalonia UI
My first approach to building graphical desktop applications on Linux was Avalonia UI.
Avalonia is an open-source, cross-platform UI framework for .NET. It allows developers to build desktop applications for Linux, Windows, and macOS using C# and XAML. One of its interesting advantages is that its XAML-based interface development feels familiar to developers who have worked with WPF.
To create a new application, I installed the Avalonia project templates:
Then I created my first desktop project:
After entering the project directory, I could run the application with:
The framework provides the tools needed to create windows, buttons, text fields, menus, and other graphical interface elements. This makes Avalonia a practical choice when the goal is to build native desktop applications that can run on Linux.
Tip: The first NuGet package restore can take time, especially with a slow or unstable Internet connection. Once the required packages are downloaded, subsequent development becomes much easier.
3. Web Applications with ASP.NET Core
The second path is web development. ASP.NET Core is Microsoft's cross-platform framework for building modern web applications, web APIs, and backend services.
Unlike desktop applications, web applications do not require a traditional graphical desktop window. The application runs on a web server, while users interact with it through a browser.
I created my first Razor Pages application with:
Then I entered the project directory and started the application:
I could access the application through Firefox at: http://localhost:5080
Razor Pages provides a convenient way to combine HTML-based interfaces with C# application logic. For example, I can create a web page containing input fields and buttons, then use C# to process user input and display the results. This approach is particularly interesting for building management systems, agricultural applications, dashboards, and database-driven business software.
4. What About WPF on Linux?
The third technology I wanted to explore was Windows Presentation Foundation (WPF). WPF is an established Microsoft framework for building Windows desktop applications using C# and XAML.
It offers powerful capabilities, including:
- Graphical user interfaces
- Data binding
- Layout management
- Controls and templates
- Two-dimensional and three-dimensional graphics
- Styling and animations
However, there is an important limitation: WPF is Windows-only. It cannot run natively on Fedora or other Linux distributions.
It is possible to edit WPF source code on Linux and configure a project for Windows targeting. For example, a WPF project file (.csproj) can include:
This enables cross-targeting builds, provided the required Windows targeting components can be restored. However, building a Windows-targeted application on Linux does not make it executable as a native Linux application. Running and properly testing the WPF interface still requires Windows.
For Linux desktop development, Avalonia is the more suitable choice.
5. Comparing the Three Development Paths
| Technology | Main Purpose | Runs Natively on Linux? |
|---|---|---|
| WPF | Windows desktop applications | No |
| Avalonia UI | Cross-platform desktop applications | Yes |
| ASP.NET Core | Web applications and APIs | Yes |
Each technology solves a different problem. WPF is relevant when developing specifically for Windows. Avalonia is a strong option for cross-platform desktop software. ASP.NET Core is suitable for websites, web applications, and backend services.
6. One Programming Language, Multiple Possibilities
One of the most interesting aspects of the modern .NET ecosystem is that I can use C# across these different development areas. The programming language remains C#, but the application framework and deployment target determine where and how the application runs.
This opens up interesting opportunities for developers who prefer Linux but still want to work within the Microsoft .NET ecosystem.
My next step is to explore these technologies through practical projects, starting with a simple desktop application, then a web application, and eventually a more complete farm management system. I believe that learning a programming language becomes much more meaningful when it leads to building useful software.
Linux is not a barrier to learning C# or building modern .NET applications. It is a capable development environment in its own right.