C# Development on Linux

Monday, Oct 30, 2023

C# has a reputation for being “Microsoft’s Language” or “Microsoft Java.” It may be true that C#‘s flagship tooling requires Windows to operate. However, .NET Core was designed with cross-platform use in mind. As long as your C# project does not use Windows-specific libraries (such as WinForms and WPF), your .NET Core project should be able to work on Linux. Great, but how is the C# experience for developers on Linux?

Tooling

First and foremost: there is no Visual Studio here. Your best options are Visual Studio Code or VSCodium with proper extensions. Without Visual Studio, you will rely on the dotnet CLI to do things such as get NuGet packages. This may seem worse compared to Visual Studio’s NuGet GUI, but nearly every other package manager operates through a CLI (such as npm, cargo, and pip) as well as jiving nicely with Linux’s commandline emphasis. It’s easy to keep a pane on tmux open just for your dotnet commands. If you use Vim, OmniSharp has good instructions for how to set up csharp-ls. csharp-ls has worked for me in the past when I only had .NET 7 on my Debian machine, but once I had to install .NET 6 as well, csharp-ls stopped working. The C# VSCode and VSCodium extensions still work though.

Adoption

I wanted to make a C# GTK Linux application that could send virtual key commands for fun. I was able to find GTKSharp to handle making GTK applications. It works but the documentation is sparse. However, there are no actively maintained Xlib bindings that I could find. If I wanted to feasibly make this program and still use C#, I’d have to compile native modules written in something like C, C++, or Rust and call external functions. For more standard and less system-specific programs, C# under .NET Core works fine, just know that less people are actively developing C# bindings for Linux-specific libraries than other languages.

Conclusion

C# development on Linux is interesting because it’s different. It doesn’t feel like it should work going into it, but it definitely does. As long as you are aware of the limitations, it can be just as fulfilling as developing using any other strongly typed object-oriented language on Linux.

Go back to Blog