45

I try to open a Unity3D project with VSCode under Linux (Ubuntu 18.10). The omnisharp extension doesn't load the project, saying assemblies were not found.

It may seems very stupide, but i'm not really used to .Net yet, and i have been stuck with this error for quite some days now. I have been trying re-installing dotnet (even using the snap package), mono, vscode and the omnisharp extension.

So any help is welcome ! :)

Unity version : 2018.3.1f1

Logs :

dotnet -- info

.NET Core SDK (reflecting any global.json): Version: 2.2.103 Commit: 8edbc2570a Runtime Environment: OS Name: ubuntu OS Version: 18.10 OS Platform: Linux RID: ubuntu.18.10-x64 Base Path: /usr/share/dotnet/sdk/2.2.103/ Host (useful for support): Version: 2.2.1 Commit: 878dd11e62 .NET Core SDKs installed: 2.2.103 [/usr/share/dotnet/sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.2.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App] 

mono --version

Mono JIT compiler version 4.6.2 (Debian 4.6.2.7+dfsg-1ubuntu1) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: __thread SIGSEGV: altstack Notifications: epoll Architecture: amd64 Disabled: none Misc: softdebug LLVM: supported, not enabled. GC: sgen 

The full log error :

 Starting OmniSharp server at 1/26/2019, 7:13:55 PM Target: /home/eyap/Projects/Unity/TestProject/TestProject.sln OmniSharp server started. Path: /home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/run PID: 30136 [info]: OmniSharp.Stdio.Host Starting OmniSharp on ubuntu 18.10 (x64) [info]: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 1 MSBuild instance(s) 1: StandAlone 15.0 - "/home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin" [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator MSBUILD_EXE_PATH environment variable set to '/home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/MSBuild.dll' [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: StandAlone 15.0 - "/home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin" MSBuildExtensionsPath = /home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild BypassFrameworkInstallChecks = true CscToolPath = /home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/Roslyn CscToolExe = csc.exe MSBuildToolsPath = /home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin TargetFrameworkRootPath = /usr/lib/mono/xbuild-frameworks [info]: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in '/home/eyap/Projects/Unity/TestProject'. [info]: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files [info]: OmniSharp.WorkspaceInitializer Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration. [info]: OmniSharp.MSBuild.ProjectSystem Detecting projects in '/home/eyap/Projects/Unity/TestProject/TestProject.sln'. [info]: OmniSharp.MSBuild.ProjectManager Queue project update for '/home/eyap/Projects/Unity/TestProject/Assembly-CSharp.csproj' [info]: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in '/home/eyap/Projects/Unity/TestProject'. [info]: OmniSharp.Script.ScriptProjectSystem Could not find any CSX files [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider [info]: OmniSharp.WorkspaceInitializer Configuration finished. [info]: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location '/home/eyap/Projects/Unity/TestProject' on host 30056. [info]: OmniSharp.MSBuild.ProjectManager Loading project: /home/eyap/Projects/Unity/TestProject/Assembly-CSharp.csproj [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. [warn]: OmniSharp.MSBuild.ProjectManager Failed to load project file '/home/eyap/Projects/Unity/TestProject/Assembly-CSharp.csproj'. /home/eyap/Projects/Unity/TestProject/Assembly-CSharp.csproj /home/eyap/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/Microsoft.Common.CurrentVersion.targets(1195,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. [fail]: OmniSharp.MSBuild.ProjectManager Attemped to update project that is not loaded: /home/eyap/Projects/Unity/TestProject/Assembly-CSharp.csproj 
1
  • For future viewers : I decided to keep the accepted answer as that was the one that made it work for me at the time. However, please take a look at the highest voted answer for a more recent solution. Commented Mar 30, 2022 at 8:06

9 Answers 9

47

Tried the steps mentioned here, did not resolve the error. Had to do change the omnisharp.useGlobalMono option to always. This worked for C# extension for VS Code=1.23.2.

Source: Reddit Post

Your error output tells me that you're using the official C# extension for VS Code. The latest version of said extension, 1.23.2, has this to say in its changelog:

For Mono-based development (e.g. Unity) that requires full .NET framework, you need to set "omnisharp.useGlobalMono": "always". This 

is needed until Mono upgrades their bundled MSBuild version

The default setting, auto, does not work. Switch it to always and restart the extension. Alternatively you could downgrade to 1.23.1.

Sign up to request clarification or add additional context in comments.

11 Comments

This worked for me on VSCode 1.49.1, Unity 2020.1.6f1, and Mono 6.10.0 Stable without modifying PATH or any environment variables
Finally I got my Intellisense working like a charm after this step. Definitely made my day, thanks!!
You are my hero, this saved my evening!
On a Mac -> Code -> Preferences -> Settings -> type "use global mono", update config to always.
This didn't resolve it for me on Windows 10, I still get "The reference assemblies for .NETFramework,Version=v4.7.1 were not found." :(
|
31

I had the same issue but on OSX. Installing latest version of Mono cleared up the missing .net v4.7.1 framework references.

I installed Mono V5.18.0 from https://www.mono-project.com/download/stable

Update: See comment below regarding global omnisharp setting

5 Comments

That might be it ! I previously installed mono just as they describe on their website, but i wrongly assumed that it was up-to-date. But it's not the case for Ubuntu 18.10 (it's still in 4.6).... I will try that tomorrow, thanks a lot !
This worked for me. I guess the last Unity update I installed bumped the required version number up past what the Ubuntu Apt sources provide.
'''sudo apt upgrade mono-devel'''. The current latest version is 6.10
I have the latest Mono and I'm still getting this problem.
Can confirm this work on Ubuntu 18.04. Thanks a bunch!
27

I was in the same situation and I found a workaround here : https://github.com/Microsoft/msbuild/issues/2728

You have to export FrameworkPathOverride=/lib/mono/4.5 and the .NETFramework will be found.

4 Comments

thanks, for this answer. worked for me on macOS. added that variable to my shell config.
where do you type that export line? how does Unity or VS Code know how to find that export?
This worked for me: export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current
That's the problem exactly, You saved my day, Thanks
13

I had the same issue and here is how I fixed it.

  1. Download the latest stable Mono from here and install.

  2. Add FrameworkPathOverride to the .bash_profile

export FrameworkPathOverride=/Library/Frameworks/Mono.framework/Versions/Current 

Restart VSCode and It works.

Comments

5

For Windows 10 users out there:


If you're still encountering this Omnisharp error:

The reference assemblies for .NETFramework,Version=v4.7.1 were not found. 
  1. Close VS Code if it's already open

  2. Download and Install .NETFramework 4.7.1 Developer Pack
    https://dotnet.microsoft.com/en-us/download/dotnet-framework/net471
    (VS Code might suggest newer versions but as of 3/25/2022 they don't work)

  3. Reopen the Unity Project in VS Code


The steps above should resolve the issue, but if you're still having problems (e.g., Intellisense not working properly), try adjusting your Unity settings:

  1. Open your Unity project, click Edit > Project Settings... > Player > Other Settings > API Compatibility Level (Under Configuration)

  2. Change API Compatibility Level to .NET 4.x

  3. Restart Unity & VS Code

Comments

4
  1. In linux mint 18.3 Sylvia (ubuntu 16.04) install mono-devel like https://www.mono-project.com/download/stable/#download-lin.

  2. Then execute in terminal export FrameworkPathOverride=/etc/mono/4.5

  3. Open vs code and works.

1 Comment

Installing latest mono didn't help me. But the export fixed the problem, thanks!
4

In Linux mint 18.3 Sylvia (Ubuntu 16.04) install mono-devel like https://www.mono-project.com/download/stable/#download-lin. Then execute in terminal

export FrameworkPathOverride=/etc/mono/4.5 

Open VScode and it works.This is what worked for me on a clean install of Ubuntu 20.04.

Comments

0

After one day researching whats going wrong. with .NETFRAMEWORK 4.7 on ubuntu and unity. I solved this by changing omnisharp:useglobalmenu to always inside VSCODE setting. here is a solution link I found https://github.com/OmniSharp/omnisharp-vscode/issues/3613#issuecomment-677451385

Comments

0

On newer OmniSharp versions (for .NET 6 development) the "Omnisharp: Use modern Net" option needs to be disabled. Maybe change it for the local workspace only in order to keep your non-unity .NET core projects unaffected.

VS Code: File > Preferences > Settings (optional: > Workspace tab) > Omnisharp: Use modern net

Alternatively change the .vscode/settings.json file, inside either your home folder (global setting) or the project workspace (local setting).

.vscode/settings.json: { [...] "omnisharp.useModernNet": false, [...] }

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.