Omnisharp-vscode: .NETFramework not found in macOS

Created on 14 May 2019  路  42Comments  路  Source: OmniSharp/omnisharp-vscode

Issue Description

I get this message in the output of VSCode

[fail]: OmniSharp.MSBuild.ProjectLoader
 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.

Steps to Reproduce

Fresh macOS install, install the newest .NET SDK, install the newest VSCode with OmniSharp
Start a Unity C# project

Expected Behavior

Actual Behavior

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.33.1
C# Extension: 1.19.1

Mono Information
OmniSharp using built-in mono

Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 2.2.106
Commit: aa79b139a8

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.14
OS Platform: Darwin
RID: osx.10.14-x64
Base Path: /usr/local/share/dotnet/sdk/2.2.106/

Host (useful for support):
Version: 2.2.4
Commit: f95848e524

.NET Core SDKs installed:
2.2.106 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download


Visual Studio Code Extensions

|Extension|Author|Version|
|---|---|---|
|atom-keybindings|ms-vscode|3.0.6|
|azure-account|ms-vscode|0.8.3|
|change-case|wmaurer|1.0.0|
|code-settings-sync|Shan|3.2.9|
|code-spell-checker|streetsidesoftware|1.7.10|
|csharp|ms-vscode|1.19.1|
|csharpfixformat|Leopotam|0.0.81|
|EditorConfig|EditorConfig|0.13.0|
|gremlins|nhoizey|0.9.0|
|ignore-gitignore|stubailo|1.0.1|
|Material-theme|zhuangtongfa|2.23.0|
|ruby|rebornix|0.22.3|
|seti-icons|qinjia|0.1.3|
|shaderlabvscodefree|amlovey|1.1.3|
|tabsanity|jedmao|0.0.11|
|terminal-tabs|Tyriar|0.2.0|
|unity-code-snippets|kleber-swf|1.3.0|
|unity-debug|Unity|2.7.2|
|vscode-open-in-sourcetree|morrislaptop|0.6.0|
|vscode-subword-navigation|ow|1.2.0|
|vscode-todo-plus|fabiospampinato|4.13.0|
|vscode-toggle-quotes|BriteSnow|0.3.2|
|vscode-unitymeta|PTD|0.0.5|;

Most helpful comment

I fixed this by setting "Use global mono" to "always" in VS Code

image

All 42 comments

In order to be able to use Unity projects targeting full .NET framework on a Mac, .NET SDK is not enough. You should also install Mono - https://www.mono-project.com/download/stable/

@filipw Thanks! i've tried it already, do i need to do something after i've installed mono? because it didnt change any of the vscode errors.

could you set "omnisharp.loggingLevel": "debug", retry and post the OmniSharp log here?

@filipw thanks, i will try again in 8 hours, the affected machine is not available to me right now

@filipw I've tried to install mono again and this time I've used the v5.20.1 version and it worked, thanks

I seem to have this same problem. Have tried installing v6.0.0 (latest) and v5.20.1 (same as @antpaw reported working). I've tried rebooting the machine after.

I'm using Unity, so I also tried removing the .csproj and .sln files and letting Unity update them again after installing the mono .NET SDK. I do see that the .csproj files contain a hint paths like this:

/Applications/Unity/Hub/Editor/2018.4.6f1/Unity.app/Contents/MonoBleedingEdge/lib/mono/4.7.1-api/System.dll

The referenced path exists, but I'm wondering if there is some conflict between this version of the runtime that has being installed with Unity and the system-installed one which seems to live at /Library/Frameworks/Mono.framework/Versions/5.20.1/lib/mono/4.7.1-api/

I enabled the debug logging level, and I've attached the output. I wonder if either @filipw or @antpaw might have some tips to get this working?

omnisharp.loggingLevel.debug.log

@andy-block can you post your dotnet --info ?

@antpaw Sure thing; dontnet --info gives:

.NET Core SDK (reflecting any global.json):
 Version:   2.2.401
 Commit:    729b316c13

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.2.401/

Host (useful for support):
  Version: 2.2.6
  Commit:  7dac9b1b51

.NET Core SDKs installed:
  1.0.4 [/usr/local/share/dotnet/sdk]
  2.0.2 [/usr/local/share/dotnet/sdk]
  2.2.401 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

I seem have this resolved now. I think what fixed it was:

  1. I had something in my .profile which was adding a path entry that pointed to mono within Unity (/Applications/Unity/Hub/Editor/[unityversion]/Unity.app/Contents/Mono/bin/). I switched this to instead reference the system installed mono binary path (/Library/Frameworks/Mono.framework/Versions/Current/bin/).
  2. I quit Unity and VS code, deleted the csproj and sln files, and restarted.

After that things seem to be working again. I had not realised that the PATH set up in my .profile would be used here (I was thinking it would only affect shells), but I guess I was wrong? Or else it was something else that caused it to get fixed. Anyway, hope the above is of use to someone.

Having a similar issue after upgrading .Net Core SDK to 2.2.4 from 2.2.1 as I needed to resolve https://github.com/dotnet/core/issues/2540 issue.

dotnet version: 2.2.402
Mono JIT version: 6.0.0.327
msbuild version: 16.1.8x

 Microsoft.Common.CurrentVersion.targets(1175, 5): [MSB3644] The reference assemblies for
 .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack
 (SDK/Targeting Pack) for this framework version or retarget your application. You can
 download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

It seems switching to MSBuild 15 resolves the problem.

Faced the exact same problems above and tried everyone's suggestions. Nothing worked for me, until I tried opening the project in Visual Studio for mac. Suddenly, VSCode works completely fine.

Absolutely no idea why. It doesnt appear to have modified the soln files or anything like that?

Hopefully that helps someone

 dotnet: 3.1.102
mono: 6.8.0.105
msbuild: 16.5.0-ci

Installing mono solved my problem.

Installing mono solved my problem.

Installing mono was also the solution in my case.

In order to be able to use Unity projects targeting full .NET framework on a Mac, .NET SDK is not enough. You should also install Mono - https://www.mono-project.com/download/stable/

After installing mono I was able to get my issue resolved. Thank you!

I had to install the latest stable mono AND add it to the path (/Library/Frameworks/Mono.framework/Versions/Current/bin)

  1. I had something in my .profile which was adding a path entry that pointed to mono within Unity (/Applications/Unity/Hub/Editor/[unityversion]/Unity.app/Contents/Mono/bin/). I switched this to instead reference the system installed mono binary path (/Library/Frameworks/Mono.framework/Versions/Current/bin/).

Looks like I have a similar issue.

Already tried installing Mono 6.8 and 5.2
Installed VisualStudio For Mac - it opens project successfully

dotenv -V:

.NET Core SDK (reflecting any global.json):
 Version:   3.1.301
 Commit:    7feb845744

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.1.301/

Host (useful for support):
  Version: 3.1.5
  Commit:  65cd789777

.NET Core SDKs installed:
  3.1.101 [/usr/local/share/dotnet/sdk]
  3.1.300 [/usr/local/share/dotnet/sdk]
  3.1.301 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.18 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

printenv:

TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM_PROGRAM_VERSION=421.2
PATH=/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands
PWD=/Users/dtx
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/dtx
LOGNAME=dtx
LC_CTYPE=UTF-8
DISPLAY=/private/tmp/com.apple.launchd.TjWaEbk33v/org.macosforge.xquartz:0
_=/usr/bin/printenv

Also tried to add '/Library/Frameworks/Mono.framework/Versions/Current/bin' to the path...

I had to put export FrameworkPathOverride to ~/.bash_profile to make to it work

I fixed this by setting "Use global mono" to "always" in VS Code

image

@tomduncalf I hope we meet one day so I can buy you a beer!, Tried everything for 4 hours and this did the final trick!

I fixed this by setting "Use global mono" to "always" in VS Code

image

This has solved the problem for me.

I fixed this by setting "Use global mono" to "always" in VS Code

image

This helped me as well

We all owe @tomduncalf a beer. Solid fix!

I fixed this by setting "Use global mono" to "always" in VS Code

image

It works!

I fixed this by setting "Use global mono" to "always" in VS Code

image

Absolute lifesaver

I fixed this by setting "Use global mono" to "always" in VS Code

image

This worked for me as well, after several hours of trying other things.

@tomduncalf Thank you so much~!

I fixed this by setting "Use global mono" to "always" in VS Code

image

thank you! fixed it for me

I fixed this by setting "Use global mono" to "always" in VS Code

image

Amazing, thank you so much.

I fixed this by setting "Use global mono" to "always" in VS Code

image

Another virtual beer for @tomduncalf (fixed for me)

@tomduncalf omg life saver!

Glad I could help you all, was tearing my hair out but found this solution on another issue. Seems like a questionable breaking change, probably warrants some kind of hotfix!

I have updated the "known issues" on the release notes https://github.com/OmniSharp/omnisharp-vscode/blob/master/CHANGELOG.md#known-issues-in-1231, this state of affairs is currently blocked by Mono

There is an additional explanation on another thread that I linked above and we also posted this info in the chabgelog. Sorry for the trouble 馃檹. it seems that for some reason this thread is easier to find than official release notes

I fixed this by setting "Use global mono" to "always" in VS Code

image

SENDING TRUCKLOAD OF BEER

I fixed this by setting "Use global mono" to "always" in VS Code

image

You saved me! So simple yet so hidden. (You actually made me comment in github for the first time)
Virtual Beer

I fixed this by setting "Use global mono" to "always" in VS Code

image

Thank you @tomduncalf. It helped me to fix the same issue.

I fixed this by setting "Use global mono" to "always" in VS Code

image

It worked ! Thanks!

Please someone close this issue!!

I fixed this by setting "Use global mono" to "always" in VS Code
image

It works!

Don't know why but this works. Thanks!

Thank you! Several rounds of virtual micro-brews for @tomduncalf as this fixes this issue for me on GNU/Linux (Debian 10) with the following prerequisites:

  • Install Mono SDK that matches the version of that used by your tools (eg: Unity, Godot, etc). I compiled from mono source: https://github.com/mono/mono using git tag mono-6.8.0.123 which corresponds to .NET 4.7.1.
  • eg:
   git clone --recursive https://github.com/mono/mono;
   cd mono; 
   git checkout -b my-mono-6.8.0.123 mono-6.8.0.123;
   ./autogen.sh;
   make;
   make check;
  • Install various dotnet items from Microsoft (likely an optional step?):

    • add/edit /etc/apt/sources.list.d/microsoft-prod.list with deb [arch=amd64] https://packages.microsoft.com/debian/10/prod buster main

    • sudo apt install dotnet-sdk-3.1

  • (totally optional step) Switch target in your tools (eg: Unity) to .NET 4.x
  • Make the OmniSharp VSCode configuration change by clicking on the little gear on the ms-dotnettools.csharp extension in the extensions tab.
  • AND PRESTO!

@tomduncalf you are the best! 馃憤

given that there is not much to discuss anymore, I will lock this issue to prevent sending notifications to every participant and subscriber upon each comment

see https://github.com/OmniSharp/omnisharp-vscode/issues/4007#issuecomment-677405332 for the background explanation and https://github.com/OmniSharp/omnisharp-vscode/blob/master/CHANGELOG.md#known-issues-in-1232 for the Known Issue note in official changelog

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwbay picture jwbay  路  3Comments

Alumniminium picture Alumniminium  路  3Comments

ZeldaZocker picture ZeldaZocker  路  3Comments

olfek picture olfek  路  3Comments

ghost picture ghost  路  3Comments