question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to load .NET 4.6 project in VS Code / Mac even with mono-mdk and stable mono installed

See original GitHub issue

Environment 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

  1. Ensure mono and/or mono-mdk is installed
  2. Open project that targets .NET Framework 4.6 in VS Code on macOS
  3. 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:closed
  • Created 5 years ago
  • Comments:25 (1 by maintainers)

github_iconTop GitHub Comments

14reactions
bitinncommented, Aug 2, 2018

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:

The reference assemblies for framework “.NETFramework,Version=v4.7.1” were not found`

It’s easily fixed by updating to latest mono (5.12 at the moment)

https://www.mono-project.com/download/stable/

10reactions
mcclurecommented, Jun 25, 2018

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

[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/Users/mcc/work/u/SRProject2/Assembly-CSharp.csproj'.
/Users/mcc/work/u/SRProject2/Assembly-CSharp.csproj
/Users/mcc/.vscode/extensions/ms-vscode.csharp-1.15.2/.omnisharp/1.30.1/omnisharp/msbuild/15.0/Bin/Microsoft.Common.CurrentVersion.targets(1140,5): Error: The reference assemblies for framework ".NETFramework,Version=v4.7.1" 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.

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to load .NET 4.6 project in VS Code / Mac even with mono ...
Ensure mono and/or mono-mdk is installed · Open project that targets .NET Framework 4.6 in VS Code on macOS · Observe OmniSharp Log...
Read more >
Mac Visual Studio cannot be launched due to Mono Framework
Could not launch Visual Studio. This application requires Xamarin.Mac native library side-by-side. Please download and install the latest version of Mono.
Read more >
Download - Stable - Mono Project
Install this package if you run into trouble making HTTPS connections. The package mono-xsp4 should be installed for running ASP.NET applications. 3 Verify ......
Read more >
How to install Mono on macOS so mono works in terminal?
In OS X El Capitan, run the following in Terminal to support mono command export PATH=/Library/Frameworks/Mono.framework/Versions/Current/bin/:${PATH}.
Read more >
Can't launch fiddler.exe in Fiddler | Telerik Forums
After installing mono and doing /Library/Frameworks/Mono.framework/Versions/4.6.2/bin/mozroots --import --sync, I extracted the zip file in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found