Search code examples
c#macosvisual-studio-codemonoomnisharp

MacOS/VisualStudioCode/Omnisharp missing .NET Framework 4.6.1


I'm on macOS Catalina running:

  • vscode 1.48.1
  • ms-dotnettools.csharp 1.23.1 (which is omnisharp underneath)
  • Visual Studio For Mac 8.7.3
  • Mono MDK 6.12.0.91

I have a project that targets .NET 4.6.1. I use vscode for this project. I also have another project that uses Visual Studio For Mac for Xamarin reasons. Unfortunately, it seems that the later versions of Visual Studio For Mac require at least Mono MDK 6.10.x. That version doesn't appear to support .NET 4.6.1. This means Omnisharp can't load the projects for vscode project. I've tried downgrading the Mono MDK without success for the vscode project. All my googling gets me to the download pages for the developer packs for Windows that have .NET framework 4.6.1, which are useless, or ways to force Omnisharp to see a 4.6.1 framework at some other path by setting an environment variable, FrameworkPathOverride, to the appropriate place, which doesn't exist on my system. At this point the only path I can see is to retarget my 4.6.1 application to a later framework but that will take forever. All I really need is a 4.6.1 framework for macOS. Halp?

EDIT: Yes, I know .NET is for Windows and Mono is for everything else. Mono provides compatibility with .NET versions and Omnisharp has handled this properly in the past. The problem only appeared after updating Visual Studio For Mac and the Mono MDK.

EDIT: Solved, see accepted answer for details


Solution

  • The issue seems to have stemmed from Omnisharp's decision to include mono internally. They default to that version of the compiler, which isn't geared for .NET Framework but dotnet core. There is a setting in vscode that forces Omnisharp to use the globally installed Mono instead. Setting that to "always" fixes this issue. Open vscode settings and search for "global mono". Set the "Omnisharp: Use Global Mono" setting to "always." Alternatively, open your settings.json file and add "omnisharp.useGlobalMono": "always".