In from the cold

Finally making Linux and .NET get along

Alistair Chapman

@agc93

Who am I?

Alistair Chapman

 

agc93

 

agc93

.NET MVP

Information Security Architect @ Red Hat

Walking, talking case of impostor syndrome

The Plan

(likely going to be abandoned about 5 minutes in)

  • History Lesson
  • The Tale of Two Platforms
  • Building .NET apps for Linux
  • Bridging the platform gap

The History Lesson

We've been here before...

(or why the Linux community looks at .NET like an aggressive leper)

A history of cross-platform .NET

The Tale of Two Platforms

Assert.AreNotEqual(".NET Core", "Mono");

Building .NET apps for Linux

  • Preparing your environment
  • Building your app
  • Test, package, bundle
  • Deployment and running

Building .NET apps for Linux

Preparing your environment

Building .NET apps for Linux

Preparing your environment

(this time like a hipster)

Building .NET apps for Linux

Building your app

Building .NET apps for Linux

Test, package and bundle your app

Deployment and Operations

  • .NET Core has separate runtime and SDK
    • Build requires SDK
    • FDD requires runtime
    • SCD requires only dependencies!
  • .NET Core 2.0 includes drastically better Linux support
    • and distro-portable deployments!

Deployment and Operations

(ASP.NET Core apps)

  • Each app uses an isolated server process
  • Kestrel is included out-of-the-box
  • Apps can be managed and monitored with systemd
[Unit]
Description=Example .NET Web API Application running on Ubuntu

[Service]
WorkingDirectory=/var/aspnetcore/
ExecStart=/usr/bin/dotnet /path/to/mvc/app.dll
Restart=always
RestartSec=10
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production

[Install]
WantedBy=multi-user.target

Bridging the Platform Gap

Making Linux a first-class .NET platform

Bridging the platform gap

  • Basically every supported distro uses DBus
  • Perfect for inspecting and controlling hardware/OS
  • Tmds.Dbus provides C# API
  • Can also be used to control systemd services
    • (requires some Polkit changes)

Connecting and controlling the underlying platform

Bridging the platform gap

Unsolicited advice for library authors

  • Always target netstandard*
  • Test on multiple distros
  • Be aware of logging
  • If possible, set up xplat CI/CD
  • Be open/gentle with collaborators
  • Seek help!

Alistair Chapman

@agc93

(essentially everywhere)

 

 

https://agchapman.com/talks

https://blog.agchapman.com/