February 11, 2017

Unity3D, VS Code, OS X and ‘The reference assemblies for framework “.NETFramework,Version=v3.5” were not found’ error

Here’s how I fixed this error. It happened to me in this environment:

I had this error inside of VS Code when I opened up a Unity project:

The reference assemblies for framework “.NETFramework,Version=v3.5” 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.

Also, VS Code’s code completion did not work. Even with the right version of OpenSSL:

openssl version
OpenSSL 1.0.2k  26 Jan 2017

and dotnet:

dotnet

Microsoft .NET Core Shared Framework Host

  Version  : 1.1.0
  Build    : 928f77c4bc3f49d892459992fb6e1d5542cb5e86

I found this fix here: https://github.com/OmniSharp/omnisharp-vscode/issues/1004

The solution was to install mono with brew

brew install mono

with that, I could run mono in the terminal

mono --version
Mono JIT compiler version 4.6.2 (Stable 4.6.2.16/ac9e222 Sun Jan  8 00:00:20 GMT 2017)
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
    LLVM:          supported, not enabled.
    GC:            sgen

just to prove it is installed. When I opened VS Code again, the OmniSharp extension found mono and let me know in its own output window while starting up and loading the project in VS Code:

iscovered Mono file path: /usr/local/bin/mono
Resolved symbolic link for Mono file path: /usr/local/Cellar/mono/4.6.2.16/bin/mono-sgen

Then my code completion worked. Yay!