.NET 5 preview support in OmniSharp and C# Extension for VS Code

Β· 511 words Β· 3 minutes to read

As we all know, we have recently been spoiled with the first preview release of .NET 5. Additionaly, Preview 2 is just around the corner and is already available via dotnet-install scripts.

While it’s still early days, we would want that OmniSharp users can work with .NET 5 as soon as possible, so we have just added support for .NET 5 in OmniSharp.

Let me quickly walk you through what you need to do to take advantage of that.

OmniSharp 1.34.15 πŸ”—

The magic number is 1.34.15 - that’s the build of OmniSharp that supports .NET 5, and it was published on 25 March. If you are consuming OmniSharp in editor other than VS Code, you need to ensure that you use at least that version.

If you are in VS Code, with the C# Extension installed, you could - more conveniently than juggling the OmniSharp builds - install the pre-release 1.21.16 of the C# Extension, which can be found here. You’d need to download the VSIX and follow the simple instructions.

That pre-release build 1.21.16 already contains OmniSharp 1.34.15. This build should ship as stable into the VS Code Marketplace at some point next week (starting on Monday 30 March)

But it still doesn’t work! πŸ”—

In principle, to support .NET 5, we need to things:

  • latest NuGet.* packages (5.6.0) - to be able to correctly handle the net5.0 TFM (introduced in preview 2)
  • MsBuild 16.5.0

When OmniSharp starts it needs to choose the most appropriate MsBuild to use. It will use one of the two options:

  • use it’s own bundled minimal MsBuild (which in this case, supports .NET 5 already)
  • use global MsBuild from your global Mono installation (if you are on *nix and have Mono >= 6.4.0) or your global Visual Studio installation (if you are on Windows and have VS >= 16.3) installed

If you are in the situation where the first option takes effect (so you have no global Mono or no global VS), then the aforementioned OmniSharp 1.34.15 guarantees that you will have .NET 5 preview support.

If you are in the second category (so you have do have global Mono or global VS), then even if you have OmniSharp 1.34.15 / VS Code Extension 1.21.16, an outdated global Mono or VS will prrevent you from enjoying support for .NET 5. In those cases you’d need to upgrade:

  • global Mono to at least 6.10.0, which is the preview version at the time of writing
  • Visual Studio to at least 16.6P2

Additionally, though this is generally not recommend, if you are *nix systems, you can disable the usage of global Mono completely by adding the following VS Code setting:

"omnisharp.useGlobalMono": "never"

This will actually force OmniSharp to be launched only with its bundled minimal MsBuild and its own bundled minimal Mono runtime.

Future πŸ”—

In the future we will raise the minimum versions of the discovered global Mono (as mentioned, currently >= 6.4.0) and global VS (currently >= 16.3) to align with .NET 5 support, however at the moment it is too early to do so. Hope this helps.

About


Hi! I'm Filip W., a cloud architect from ZΓΌrich πŸ‡¨πŸ‡­. I like Toronto Maple Leafs πŸ‡¨πŸ‡¦, Rancid and quantum computing. Oh, and I love the Lowlands 🏴󠁧󠁒󠁳󠁣󠁴󠁿.

You can find me on Github and on Mastodon.

My Introduction to Quantum Computing with Q# and QDK book
Microsoft MVP