It took me way too long to figure this out, so I figured I’d write a concise tutorial for anyone else who wants to do C# development using Visual Studio Code installed via flatpak.
SDK Installation
You’ll need to install two SDK extensions:
flatpak install org.freedesktop.Sdk.Extension.dotnet5
flatpak install org.freedesktop.Sdk.Extension.mono6
Flatpak Configuration
Two environment variables need to be set for Visual Studio Code to find the
.NET SDK. You can use flatpak override --env VARIABLE=VALUE com.visualstudio.code
or, if you’d prefer a GUI, use the Flatseal
app.
The variables are:
PATH=/app/bin:/usr/bin:/usr/lib/sdk/dotnet5/bin
DOTNET_ROOT=/usr/lib/sdk/dotnet5
Visual Studio Code Configuration
Next, restart Visual Studio Code and install the C# extension. Go to the Extensions pane on the left (the little building blocks icon), search “C#”, and install the official extension by Microsoft.
Then go to File -> Preferences -> Settings, search “Mono Path”, and click “Edit
in settings.json”. Set it to /usr/lib/sdk/mono6
. Then go back to the Settings
tab and set “Use Global Mono” to “always”.
That should do it! You might need to restart OmniSharp or Visual Studio Code first, but the C#/.NET tools should work now. Hopefully this process will become easier in the future.