Omnisharp-vscode: Assemblies targeting .Net Framework 4.7.1 fail to load on Mac, plugin v1.21.11

Created on 27 Feb 2020  路  16Comments  路  Source: OmniSharp/omnisharp-vscode

Issue Description

When loading my Unity (v2018.4.2f) project in Visual Studio Code, the assemblies fail to load and intellisense doesn't work. This seems to have been introduced in version 1.21.11, as rolling back to v1.21.10 works fine.

Steps to Reproduce

  1. Create a project in Unity, v2018.4.2
  2. Target .Net Framework 4.7.1 by setting Scripting Runtime Version to .Net 4.x Equivalent in Edit/Project Settings/Player/Scripting Runtime Version
    image
  3. Open up the project in Visual Studio Code
  4. Observe the plugin fails to load the assemblies

Expected Behavior

The assemblies should load, allowing me to see function references and Go To implementations and definitions.

Actual Behavior

Intellisense and
image

Logs

OmniSharp log

Starting OmniSharp server at 2/27/2020, 3:58:25 PM
Target: /Users/erowe/Development/sparklite/sparklite.sln

OmniSharp server started.
Path: /Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/run
PID: 26956

    Starting OmniSharp on MacOS 10.14.6 (x64)
    DotNetPath set to dotnet
    Located 1 MSBuild instance(s)
        1: StandAlone 16.3 - "/Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild/Current/Bin"
    MSBUILD_EXE_PATH environment variable set to '/Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
    Registered MSBuild instance: StandAlone 16.3 - "/Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild/Current/Bin"
        CscToolExe = csc.exe
        MSBuildToolsPath = /Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild/Current/Bin
        CscToolPath = /Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild/Current/Bin/Roslyn
        BypassFrameworkInstallChecks = true
        MSBuildExtensionsPath = /Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild
    Detecting Cake files in '/Users/erowe/Development/sparklite'.
    Could not find any Cake files
    Detecting projects in '/Users/erowe/Development/sparklite/sparklite.sln'.
    Queue project update for '/Users/erowe/Development/sparklite/Assembly-CSharp.csproj'
    Queue project update for '/Users/erowe/Development/sparklite/Assembly-CSharp-firstpass.csproj'
    Queue project update for '/Users/erowe/Development/sparklite/Assembly-CSharp-Editor.csproj'
    Queue project update for '/Users/erowe/Development/sparklite/Assembly-CSharp-Editor-firstpass.csproj'
    Queue project update for '/Users/erowe/Development/sparklite/RBG.Mulligan.csproj'
    Detecting CSX files in '/Users/erowe/Development/sparklite'.
    Loading project: /Users/erowe/Development/sparklite/Assembly-CSharp.csproj
    Could not find any CSX files
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.EditorConfigWorkspaceOptionsProvider, Order: 200
    Configuration finished.
    Omnisharp server running using Stdio at location '/Users/erowe/Development/sparklite' on host 26922.
    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
    Failed to load project file '/Users/erowe/Development/sparklite/Assembly-CSharp.csproj'.

/Users/erowe/Development/sparklite/Assembly-CSharp.csproj
/Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1193,5): Error: 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

    Loading project: /Users/erowe/Development/sparklite/Assembly-CSharp-firstpass.csproj
    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
    Failed to load project file '/Users/erowe/Development/sparklite/Assembly-CSharp-firstpass.csproj'.

/Users/erowe/Development/sparklite/Assembly-CSharp-firstpass.csproj
/Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1193,5): Error: 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

    Loading project: /Users/erowe/Development/sparklite/Assembly-CSharp-Editor.csproj
    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
    Failed to load project file '/Users/erowe/Development/sparklite/Assembly-CSharp-Editor.csproj'.

/Users/erowe/Development/sparklite/Assembly-CSharp-Editor.csproj
/Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1193,5): Error: 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

    Loading project: /Users/erowe/Development/sparklite/Assembly-CSharp-Editor-firstpass.csproj
    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
    Failed to load project file '/Users/erowe/Development/sparklite/Assembly-CSharp-Editor-firstpass.csproj'.

/Users/erowe/Development/sparklite/Assembly-CSharp-Editor-firstpass.csproj
/Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1193,5): Error: 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

    Loading project: /Users/erowe/Development/sparklite/RBG.Mulligan.csproj
    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
    Failed to load project file '/Users/erowe/Development/sparklite/RBG.Mulligan.csproj'.

/Users/erowe/Development/sparklite/RBG.Mulligan.csproj
/Users/erowe/.vscode/extensions/ms-vscode.csharp-1.21.11/.omnisharp/1.34.11/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1193,5): Error: 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

    Attempted to update project that is not loaded: /Users/erowe/Development/sparklite/Assembly-CSharp.csproj
    Attempted to update project that is not loaded: /Users/erowe/Development/sparklite/Assembly-CSharp-firstpass.csproj
    Attempted to update project that is not loaded: /Users/erowe/Development/sparklite/Assembly-CSharp-Editor.csproj
    Attempted to update project that is not loaded: /Users/erowe/Development/sparklite/Assembly-CSharp-Editor-firstpass.csproj
    Attempted to update project that is not loaded: /Users/erowe/Development/sparklite/RBG.Mulligan.csproj

C# log

Installing C# dependencies...
Platform: darwin, x86_64

Downloading package 'OmniSharp for OSX' (46346 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'OmniSharp for OSX'

Downloading package '.NET Core Debugger (macOS / x64)' (41849 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package '.NET Core Debugger (macOS / x64)'

Downloading package 'Razor Language Server (macOS / x64)' (50424 KB).................... Done!
Installing package 'Razor Language Server (macOS / x64)'

Finished

Environment information

VSCode version: 1.42.1
C# Extension: 1.21.11

Mono Information
OmniSharp using built-in mono

Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 2.1.401
Commit: 91b1c13032

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

Host (useful for support):
Version: 2.1.3
Commit: 124038c13e

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

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.3 [/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|
|---|---|---|
|csharp|ms-vscode|1.21.11|
|docomment|k--kato|0.1.8|
|gitlens|eamodio|10.2.1|
|rainbow-csv|mechatroner|1.5.0|
|theme-dracula|dracula-theme|2.20.0|
|unity-debug|Unity|2.7.2|
|vscode-emacs|hiro-sun|0.1.1|;

Most helpful comment

In my case, I have reinstalled the previous version of omnisharp plugin then it worked

image

image

Another way to fix the issue without downgrade omnisharp plugin is to update the latest mono (https://www.mono-project.com/download/stable/).
Set Use Global Mono to always
image

All 16 comments

@edwardrowe The built-in mono does not contain reference assemblies. To fix this problem you should install the stable mono - https://www.mono-project.com/download/stable/#download-mac

This worked. Thanks so much for the help and quick feedback.

To fix this problem you should install the stable mono

I did, but it didn't help.
How should I reference installed Mono, so Unity can find missing Net Framerowrk?

@DTX-92 Can you share the omnisharp log from the Output pane?

I was able to fix a problem by modifying my ~/.bash_profile to contain export FrameworkPathOverride
thx

In my case, I have reinstalled the previous version of omnisharp plugin then it worked

image

image

Another way to fix the issue without downgrade omnisharp plugin is to update the latest mono (https://www.mono-project.com/download/stable/).
Set Use Global Mono to always
image

In my case, I have reinstalled the previous version of omnisharp plugin then it worked

image

image

it's ok

For anyone who can't find the Use Global Mono setting, go to Extension Settings at the bottom of the cog on the C# extension
image

giangchau92 Mine god man! Thank you..

image

So summary I did:
Error: The reference assemblies for .NETFramework,Version=v4.7.1
Unity 2019.4.9f1 Macos

Downgrade to
c# extension v1.23.0 as described above

Removed all csproj and regenerated it

  • Go to Unity -> Edit -> Preferences -> External Tools
  • Look for the section near the top called "Generate .csproj files for:" and click "Regenerate Project Files" with everything unchecked.

    • Then in VSCode I press "Cmd + Shift + P" and run the action for "Developer: Reload Window"

Unity 2020.1.9f1 Personal, MacOS Catalina 10.15.7 (19H2) and the problem persists on versions >1.23.0 :/

@hypeofpipe Sorry you are running into issues. The minimal Mono shipped with the C# extension does not contain 4.7.1 reference assemblies. Install the latest stable Mono 6.12.0 from https://www.mono-project.com/download/stable/ and set the omnisharp.useGlobalMono setting to "always". Also, ensure you are using the 1.2.3 VSCode Editor package in Unity.

@giangchau92 's solution worked for me. Using homebrew I installed dotnet-sdk and mono, then I installed the C# extension in VSCode and had the error in the thread's title. The plugin was at version 1.23.5, I installed version 1.23.4 and now I get no errors in the OmniSharp's log and intellisense works.

Omnisharp.log at start:

Starting OmniSharp server at 11/11/2020, 11:28:49 AM
    Target: /Users/r/Projects/MessingWithEvents/MessingWithEvents.sln

OmniSharp server started with Mono 6.12.0.
    Path: /Users/r/.vscode/extensions/ms-dotnettools.csharp-1.23.4/.omnisharp/1.37.3/omnisharp/OmniSharp.exe
    PID: 14509

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.15.7 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Mono 16.8.0 - "/usr/local/Cellar/mono/6.12.0.90/lib/mono/msbuild/Current/bin"
            2: StandAlone 16.8.0 - "/Users/r/.vscode/extensions/ms-dotnettools.csharp-1.23.4/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Mono 16.8.0 - "/usr/local/Cellar/mono/6.12.0.90/lib/mono/msbuild/Current/bin"
            CscToolExe = csc.exe
            CscToolPath = /Users/r/.vscode/extensions/ms-dotnettools.csharp-1.23.4/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/Roslyn
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/r/Projects/MessingWithEvents'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/Users/r/Projects/MessingWithEvents/MessingWithEvents.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/r/Projects/MessingWithEvents/Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/r/Projects/MessingWithEvents'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/r/Projects/MessingWithEvents/Assembly-CSharp.csproj
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/r/Projects/MessingWithEvents' on host 14487.
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file '/Users/r/Projects/MessingWithEvents/Assembly-CSharp.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/r/Projects/MessingWithEvents/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Assembly-CSharp

@hypeofpipe Sorry you are running into issues. The minimal Mono shipped with the C# extension does not contain 4.7.1 reference assemblies. Install the latest stable Mono 6.12.0 from https://www.mono-project.com/download/stable/ and set the omnisharp.useGlobalMono setting to "always". Also, ensure you are using the 1.2.3 VSCode Editor package in Unity.

Thank you!! I am using Unity 2019.4.14f1 on MacOS Catalina 10.15.7, and I noticed the package for "VSCode Editor" was on older version 1.2.2. Upgrading to 1.2.3 fixed it.

OmniSharp' debug message is also not terribly helpful because AFAIK there is no .Net Framework 4.7.1 built for Mac. So what would help me debug this issue is knowing what are the responsible parties for this framework version determination. Is it Unity? Is it VSCode Editor? Is it maybe a solution misconfiguration with a default resolving to 4.7.1?

I know OmniSharp package isn't directly in charge of these other projects, and it's important to maintain some idempotency between them. However the reality is 99.9% of users encountering this major error are coming from a Unity on Mac environment. Some from Unity on Linux too. Therefore, some awareness of how Unity interoperates with OmniSharp and VSCode would all be very much more helpful. Maybe even provide a URL tip to a OmniSharp wiki page with up-to-date information on this common issue.

Also, Unity needs to do some sanity checking for developer work environments. Something really smart for Mac developers that checks and suggests what are working configurations.

In my case, I have reinstalled the previous version of omnisharp plugin then it worked

image

image

Another way to fix the issue without downgrade omnisharp plugin is to update the latest mono (https://www.mono-project.com/download/stable/).
Set Use Global Mono to always
image

Man.. i want to hug you! I've been fighting 3 days with it and just changed to use mono always. IT'S WORKING

That "Global Mono to always" setting in VS Code was the thing I missed on the first try. Just installing the latest mono alone didn't do it. Thanks @giangchau92 !

Was this page helpful?
0 / 5 - 0 ratings