Unable to load .NET 4.6 project in VS Code / Mac even with mono-mdk and stable mono installed
See original GitHub issueEnvironment data
dotnet --info
output:
.NET Command Line Tools (2.1.4)
Product Information:
Version: 2.1.4
Commit SHA-1 hash: 5e8add2190
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/2.1.4/
Microsoft .NET Core Shared Framework Host
Version : 2.0.5
Build : 17373eb129b3b05aa18ece963f8795d65ef8ea54
VS Code version: 1.24.1 C# Extension version: 1.15.2
Steps to reproduce
- Ensure mono and/or mono-mdk is installed
- Open project that targets .NET Framework 4.6 in VS Code on macOS
- Observe OmniSharp Log window
Expected behavior
Solution and its projects should load properly, and OmniSharp server should initialize successfully.
Actual behavior
OmniSharp is unable to load the project in question and fails. The specific error is one that I have seen referenced in a few other issues on this repo:
[fail]: OmniSharp.MSBuild.ProjectLoader
The reference assemblies for framework ".NETFramework,Version=v4.6" were not found. To resolve
this, install the SDK or Targeting Pack for this framework version or retarget your
application to a version of the framework for which you have the SDK or Targeting Pack
installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will
be used in place of reference assemblies. Therefore your assembly may not be correctly
targeted for the framework you intend.
I have seen where certain versions of the mono
formula were causing problems, and also have seen the suggestion to install the mono-mdk
cask instead. So far, I have uninstalled the mono
formula entirely. As for the MDK:
$ brew cask info mono-mdk
mono-mdk: 5.12.0.226
http://www.mono-project.com/
/usr/local/Caskroom/mono-mdk/5.12.0.226 (346.3MB)
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/mono-mdk.rb
==> Name
Mono
==> Artifacts
MonoFramework-MDK-5.12.0.226.macos10.xamarin.universal.pkg (Pkg)
==> Caveats
Installing mono-mdk removes mono and mono dependant formula binaries in
/usr/local/bin and adds mono-mdk to /private/etc/paths.d/
You may want to:
brew unlink {formula} && brew link {formula}
and/or remove /private/etc/paths.d/mono-commands
I’ve also reinstalled the latest stable Mono Framework for MacOS using the downloadable package available directly from www.mono-project.com.
$ mono --version
Mono JIT compiler version 5.12.0.226 (2018-02/9824e260f56 Mon Apr 30 18:45:52 EDT 2018)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(3.6.0svn-mono-master/8b1520c8aae)
GC: sgen (concurrent by default)
Please accept my apologies if this particular iteration of the issue has already reported and resolved elsewhere. I spoke briefly offline with @DustinCampbell about it, and he suggesting posting the issue here and CC’ing @rchande.
Let me know if there additional info needed. Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:25 (1 by maintainers)
Top GitHub Comments
Just a quick note here to confirm updating mono indeed fix this issue for macOS.
I had mono 5.8.0 and Unity 2018.2 and ran into the same error when trying to start omnisharp on VSCode:
It’s easily fixed by updating to latest mono (5.12 at the moment)
https://www.mono-project.com/download/stable/
I am encountering much this same issue. I managed to hit this by creating a Unity 2018.2.0b9 project, using VS Code as my code editor, upgrading the Unity project to their “.NET 4.x equivalent” scripting runtime version and “.NET 4.x” API compatibility level, setting up an MSBuild build task in VS Code, and then running the build task. The exact error I get, in the Output pane, is
Following this, building does not seem to “do anything” (it does not notice when I ask it to compile a file with syntax errors).
I would like to stress a separate issue from the mere fact this is not working. The problem as I see it is VS Code / omnisharp does not provide information sufficient to debug this problem on my own. I do not know how to install an “SDK or targeting pack”. I could look this up, but I do not know what .NET installation VS Code is using. Are you running
/usr/local/bin/mono
? Are you running/usr/local/share/dotnet/dotnet
? (I have both mono and the CLR installed locally.) Do you have your own internal version of .NET you installed (you apparently have an internal version of MSBuild, I see its path in the error message)? My expected behavior is that if I need to install something for Omnisharp to function, that VS Code would present a clear error message, instead of a stray message in “output”, and tell me what program I need to install additions to. This problem (inadequate error message in the case of messed up dependencies) is still a problem even if the issue with Homebrew @rchande mentions is fixed and it resolves this particular error.