Development on Linux of .NET Applications
Rainer Stropek | time cockpit
Linux for .NET Dev
Options
- Linux on your PC or in a VM (on-premises or cloud) π
- Containerized environment (Docker)
- Independent of host OS (with Docker Desktop)
- No installation/update required
- .NET on docker hub π
- Cloud development environments
- E.g. GitHub Codespaces, gitpod
- Windows Subsystem for Linux (WSL 2) π
- Linux environment on Windows without VM or dual-boot
- My personal favorite
WSL 2
WSL Demos
IDE Options
IDE Options on/for Linux
- IDE on Linux
- VSCode and VSCode Forks (e.g. Cursor AI)
- JetBrains Rider π
- Any other editor with support for .NET LSP (e.g. Neovim)
- Visual Studio on Windows + Debug in container
- Docker support in Visual Studio
- Not my personal favorite
- Remote Development with VSCode and forks π
- SSH, containers, WSL, GitHub Codespaces
- My personal favorite
Remote Development Demos
.NET on Linux
.NET on Linux
- Linux support in .NET since .NET Core
- Good Linux support in recent .NET versions
- Target frameworks for .NET π
- TFM = Target Framework Moniker
- Portable vs. OS-specific
- Use multiple TFMs if applicable π
- .NET Runtime Identifier π
- Identify target platform (e.g. linux-x64)
- E.g. used when building platform-specific executables
Publishing Demos
Tips for Cross-Platform Development
Tips
- Avoid exploiting platform-specific behaviors. Examples:
- Case-insensitive file names on Windows
- Write platform-independent code. Examples:
- Use PathΒ to combine folder names
- Use Environment.NewLine
- Use UTF-8 encoding for text files
- Use Environment.GetFolderPath to get special folders
- Avoid platform-specific features. Examples:
- Configuration files or environment variables instead of Windows Registry
- gRPC over Sockets instead of Windows Named Pipes
- Open TelemetryΒ instead of Windows Event Log
Tips
- Be aware of platform specifics. Examples:
- Higher path length limit on Linux
- File permissions work differently on Windows and Linux
- Symbolic links on Linux
- Consider platform-specific implementations via DI
- Avoid platform-specific UI technologies
- Avalonia or MAUI for desktop apps
- Web UI
- Use cross-platform script platform for automation tasks
- TypeScript instead of bash
- PowerShell on Linux
Tips (Skills)
- Get foundational knowledge about Linux
- Basic commands, package management, Linux monitoring tools, networking fundamentals, etc.
- Become familiar with dotnet-related CLIs
- Frequently used when developing on Linux
- Containers are important on Linux
- Get familiar with Docker or similar technology
Q&A
Rainer Stropek | time cockpit
Developing with .NET on Linux
By Rainer Stropek
Developing with .NET on Linux
- 69