Build together, debug together. Join the community on Discord.→

Building .NET apps for Linux from any operating system

It’s 2024, and somehow, there is still a misconception that .NET cannot be used to build .NET UIs for Linux. So, let’s dispel that myth and clarify your options, much like Scott Hanselman tried, but in a lot more detail, covering:

  • .NET support for Linux
  • Building .NET UI for Linux
  • Your IDE options for building for Linux, from any operating system, using .NET

.NET support for Linux

.NET started supporting Linux with the release of .NET Core 1.0, a cross-platform version of the .NET Framework, in June 2016.

Most major Linux distributions like Ubuntu and Debian offer official .NET packages for easy installation. Alternatively, the .NET SDK installer provides a straightforward method for installation on any distribution. You can find great information at Microsoft docs about it at Install .NET on Linux distributions – .NET | Microsoft Learn

However, it is worth noting that when developers complain about the lack of .NET support for Linux, it is a statement of lack of support for building great UIs with .NET and Microsoft-provided tooling & frameworks. Let’s talk about that next.

Building .NET UI for Linux

Having clarified that .NET runs on Linux, how can you build UI’s for Linux? While Microsoft doesn’t provide a framework for it, the .NET community does – enter Uno Platform.

On Linux, Uno Platform renders XAML visual elements directly onto a hardware-accelerated Skia canvas hosted inside a minimal X11 shell window. Uno Platform takes care of the windowing, theming, D-Bus interactions, and other inputs to get your app integrated with the rest of the system.

The app will use a theme of your choosing, whether the default WinUI Fluent theme or Material, looking the same as the other targets Uno Platform supports.

For Linux targets without a window manager, such as embedded systems, Uno Platform supports rendering directly to the Linux Framebuffer using libinput for keyboard, mouse, and touch input handling.

Your IDE options for building for Linux from any OS

Now that we have clarified that .NET runs on Linux and that you can build .NET UIs for it using Uno Platform, what IDE should you use to build it? You have three options:

  1. Visual Studio for Windows
  2. Visual Studio Code (Windows, Linux, Mac)
  3. JetBrains Rider (Windows, Linux, Mac)

Developing for Linux from Visual Studio for Windows

Visual Studio for Windows stands out with its excellent .NET tooling, making it the go-to choice for many developers. However, its support for remote Linux .NET development is limited. Testing Linux-specific .NET apps requires deploying to a remote system after compiling, which isn’t ideal if you prefer a tighter edit-compile-debug loop. Despite this, it remains a powerful option for those primarily working on Windows.

Visual Studio also supports deploying to WSL, giving a good alternative to deploying to an actual Linux device, and with the support of WSLg, Uno Platform supports running your app with a GUI, while staying exclusively on Windows.

Developing for Linux from Visual Studio Code

VS Code can be used from either Windows, Mac or Linux to develop Linux apps!

Even though VS Code is a Text Editor first, it has rapidly improved and is now a robust option for .NET development. With the introduction of the C# Dev Kit and Uno Platform extension, you can develop directly on a Linux OS or even point at an Ubuntu VM and enjoy an experience akin to working directly on a Linux workstation.

Developing for Linux from Jetbrains Rider

JetBrains Rider runs natively on Mac, Windows, and Linux, making it an excellent choice if Linux is your main OS. While Uno Platform currently supports Rider, the upcoming Uno releases will introduce enhanced functionality. This makes Rider a compelling option for .NET developers seeking a native experience across different operating systems.

Bonus: Benefits of Using Uno Platform & .NET on Linux

Now that we’ve established that .NET runs on Linux, you can build beautiful UIs with Uno Platform for it, and that you can use the most popular IDEs to do so, lets talk about the benefits Uno Platform brings.

  • Consistent Development Experience: Whether building on Windows and deploying to Linux or developing .NET apps for Linux on Linux, Uno Platform provides a uniform development experience.
  • Flexibility: Supports both X11 and Framebuffer rendering, allowing targeting a wide range of devices and distros.
  • Tooling: Benefit from VS Code and Rider support and use features like Hot Reload. Additional support for Rider coming in Uno 5.3
  • “Free” apps on Windows, Mac, Web, iOS and Android. Applications you develop for Linux will just work on all other major platforms. You can choose to run the same UI you already have on Linux or create a specific look for additional platforms.

Real-World Uno Platform Applications in Linux Environments

Industrial Automation with Raspberry Pi 4

One developer used Uno Platform to power an industrial system managing complex operations like vibrating feeders, conveyor belts, and sensors on Raspberry Pi 4 devices running a lightweight Linux OS. The system is divided into two applications for enhanced performance and reliability:

 

Production Plant Monitoring and Control

In another use case, Uno Platform was used to control and gather real-time information from over 100 machines in a production plant. The application uses gRPC for efficient communication, demonstrating Uno Platform’s compatibility with modern protocols and its ability to manage complex, data-intensive operations.

Background Service: Manages overall system monitoring using gRPC server or Sockets to coordinate commands and events, ensuring system synchronization. It maintains local storage interactions even during database disconnects to ensure data integrity and uninterrupted operation.

Uno Calculator

Uno Calculator:
In addition to Ubuntu, Uno Calculator runs on Red Hat Enterprise Linux, Linux Mint, Debian, Fedora, openSUSE, Manjaro, Kubuntu, KDE Neon, elementary OS, CentOS, and Arch Linux, making it versatile across various Linux environments.
Download Uno Calculator on the Snap store

Spotify Remote:

Spotted in the Twitter wild, Uno Platform with .NET was used to create a Spotify Remote on a Raspberry Pi Zero 2 with a Pimoroni display.

Linux Development Docs
Discover our Linux X11 and Linux Framebuffer documentation.

A Look to the Future​

With this we consider the myth dispelled – not only that you can build beautiful UIs for Linux using .NET and its ecosystem, but you can also be very productive with it and have your app run everywhere else.

The .NET community is increasingly eyeing Linux for desktop and IoT development, driven by a push towards more open, versatile platforms. This isn’t just about accessing new platforms; it’s about applying .NET skills to a broader range of applications, from Linux desktops to IoT devices that power our everyday lives. Uno Platform empowers this shift by offering .NET developers a familiar way to expand their reach into Linux environments, providing the tools to create beautiful and performant desktop and smart device applications while staying within the familiar embrace of .NET.

Tags:

Related Posts

Uno Platform 5.2 LIVE Webinar – Today at 3 PM EST – Watch