Omnisharp-vscode: Unable to resolve assemblies in existing Unity project

Created on 6 Jan 2018  路  18Comments  路  Source: OmniSharp/omnisharp-vscode

Environment data

dotnet --info output:

.NET Command Line Tools (2.0.2)

Product Information:
 Version:            2.0.2
 Commit SHA-1 hash:  a04b4bf512

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.0.2/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version: 1.19.1
C# Extension version: 1.13.1

Steps to reproduce

Open pre-existing Unity project in VS Code.

Expected behavior

IDE features to work.

Actual behavior

Missing assembly warnings and no IDE features.

The project worked fine a few months ago; I switched to Visual Studio for Mac for a bit but trying to switch back I've been hit with this and after all of my attempts to figure out what is going on I have been unsuccessful. I created a brand new project and while I still am getting the same unable to resolve assembly warning intellisense seems to work; it's just pre-existing projects that seem to be the issue.

Full disclosure in case it is part of the issue; I'm using a compiled omnisharp-roslyn because for some reason the one shipped with the C# extension errors out on my machine.

Omnisharp log:

Starting OmniSharp server at 1/8/2018, 11:28:10 AM
    Target: /Users/mattbengston/Development/Games/spooky-jumps/spooky-jumps.sln

OmniSharp server started wth Mono
    Path: /Users/mattbengston/Development/Utils/omnisharp-roslyn/artifacts/scripts/OmniSharp.Stdio
    PID: 84470

锘縖info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.12.6 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Mono 15.0 - "/Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin"
            2: StandAlone 15.0 - "/Users/mattbengston/Development/Utils/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio/mono/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Mono 15.0 - "/Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin"
            CscToolPath = /Users/mattbengston/Development/Utils/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio/mono/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/mattbengston/Development/Games/spooky-jumps'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in /Users/mattbengston/Development/Games/spooky-jumps
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/Users/mattbengston/Development/Games/spooky-jumps/spooky-jumps.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/mattbengston/Development/Games/spooky-jumps/JumperCore.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/mattbengston/Development/Games/spooky-jumps/JumperLevelGeneration.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/mattbengston/Development/Games/spooky-jumps/spooky-jumps.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/mattbengston/Development/Games/spooky-jumps/JumperLevelEditor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/mattbengston/Development/Games/spooky-jumps/spooky-jumps.Editor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/mattbengston/Development/Games/spooky-jumps'.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/mattbengston/Development/Games/spooky-jumps/JumperCore.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Stdio.Host
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Stdio.Host
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/mattbengston/Development/Games/spooky-jumps' on host 84449.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/mattbengston/Development/Games/spooky-jumps/JumperCore.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/mattbengston/Development/Games/spooky-jumps/JumperLevelGeneration.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/mattbengston/Development/Games/spooky-jumps/JumperLevelGeneration.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/mattbengston/Development/Games/spooky-jumps/spooky-jumps.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/mattbengston/Development/Games/spooky-jumps/spooky-jumps.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/mattbengston/Development/Games/spooky-jumps/JumperLevelEditor.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/mattbengston/Development/Games/spooky-jumps/JumperLevelEditor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/mattbengston/Development/Games/spooky-jumps/spooky-jumps.Editor.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/mattbengston/Development/Games/spooky-jumps/spooky-jumps.Editor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: JumperCore
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: JumperLevelGeneration
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/mattbengston/Development/Games/spooky-jumps/Temp/UnityVS_bin/Debug/JumperCore.dll'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: spooky-jumps
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/mattbengston/Development/Games/spooky-jumps/Temp/UnityVS_bin/Debug/JumperCore.dll'
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/mattbengston/Development/Games/spooky-jumps/Temp/UnityVS_bin/Debug/JumperLevelEditor.dll'
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/mattbengston/Development/Games/spooky-jumps/Temp/UnityVS_bin/Debug/JumperLevelGeneration.dll'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: JumperLevelEditor
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/mattbengston/Development/Games/spooky-jumps/Temp/UnityVS_bin/Debug/JumperCore.dll'
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/mattbengston/Development/Games/spooky-jumps/Temp/UnityVS_bin/Debug/JumperLevelGeneration.dll'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: spooky-jumps.Editor
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/mattbengston/Development/Games/spooky-jumps/Temp/UnityVS_bin/Debug/Assembly-CSharp.dll'
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/mattbengston/Development/Games/spooky-jumps/Temp/UnityVS_bin/Debug/JumperCore.dll'
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/mattbengston/Development/Games/spooky-jumps/Temp/UnityVS_bin/Debug/JumperLevelEditor.dll'
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/mattbengston/Development/Games/spooky-jumps/Temp/UnityVS_bin/Debug/JumperLevelGeneration.dll'
Bug OmniSharp

Most helpful comment

@rchande seems like it's not related to the project but rather my machine/vscode/something super strange 馃槄

I'm on OSX and despite a couple fresh re-installs of the plugin and VSCode the default path the plugin was using was:

OmniSharp server started wth Mono
    Path: /Users/mattbengston/.vscode/extensions/ms-vscode.csharp-1.13.1/.omnisharp/omnisharp/OmniSharp.exe
    PID: 22028

This threw a ton of errors, namely:

System.TypeInitializationException: The type initializer for 'OmniSharp.Utilities.Platform' threw an exception. ---> System.IO.FileNotFoundException: Could not find file "/etc/os-release"
. . .

After comparing the output of a friends editor we noticed that his path was .omnisharp/run, so I updated my settings to:

"omnisharp.path": "/Users/mattbengston/.vscode/extensions/ms-vscode.csharp-1.13.1/.omnisharp/run",

And viola, everything works in every project with no issues.

No idea why it was using OmniSharp.exe vs run, but everything is working perfectly now; so this can probably be closed :)

All 18 comments

@bengsfort Any way you can share excerpts of how your new and old projects differ with regard to references and SDK?

@rchande seems like it's not related to the project but rather my machine/vscode/something super strange 馃槄

I'm on OSX and despite a couple fresh re-installs of the plugin and VSCode the default path the plugin was using was:

OmniSharp server started wth Mono
    Path: /Users/mattbengston/.vscode/extensions/ms-vscode.csharp-1.13.1/.omnisharp/omnisharp/OmniSharp.exe
    PID: 22028

This threw a ton of errors, namely:

System.TypeInitializationException: The type initializer for 'OmniSharp.Utilities.Platform' threw an exception. ---> System.IO.FileNotFoundException: Could not find file "/etc/os-release"
. . .

After comparing the output of a friends editor we noticed that his path was .omnisharp/run, so I updated my settings to:

"omnisharp.path": "/Users/mattbengston/.vscode/extensions/ms-vscode.csharp-1.13.1/.omnisharp/run",

And viola, everything works in every project with no issues.

No idea why it was using OmniSharp.exe vs run, but everything is working perfectly now; so this can probably be closed :)

Thanks for the detailed update @bengsfort. C# for VS Code does try to run OmniSharp.exe on Mono if there's a newer version of Mono installed. In your case, 5.4.1 appears to be installed -- probably from the VS for Mac install. This is a generally a good thing. However, based on the error you reported above, something is clearly wrong.

OmniSharp has some platform-sniffing code that, first, checks to see if is running on Windows. If not, it runs uname -s -m on bash to determine whether it is running on Darwin (OS X) or Linux. Only in the case that it determines that it is running on Linux, will it ever try and read /etc/os-release file.

So, it seems like your running OmniSharp.exe on Mono on your machine causes OmniSharp to think it's running on Linux for some reason, which is clearly super-weird. :smile:

Could you try the following for me?

  1. Open VS Code as you always do.
  2. In the VS Code Terminal pane, run the following:
/bin/bash -c 'uname -s -m'

What is the output?

@DustinCampbell sorry for the late response, the output is:

% /bin/bash -c 'uname -s -m'
Darwin x86_64

It was all working as I swapped it to the correct position, but with the latest update it's all borked again so definitely eager to try and get it to a stable state.

I'm also having issues with the same bug here. Not entirely sure who's at fault. Could be Unity 2017.3.1f1. However I didn't have trouble till VS Code just updated itself automatically in the background today, and now it's not working with the same "Unable to resolve assembly" issue.

Same, also affected.. everything used to work but now it doesn't with this error. I tested the recent VS-code (1.22.2) with Unity version back to 2017.3.0p2 on Linux with which Omnisharp definitely used to work. Sp pretty sure the breaking changes happened on the VS-Code / Omnisharp side.

Things seem to be working again.

@otri Thanks for the feedback. For reference for others on this thread, can you share your C# extension version/unity/dotnet versions? Thanks!

@otri Also, if you have the mono mdk installed, could you share that version as well?

I'm not sure how I pull versions for mono mdk, C# extension or dotnet. Had issues with Unity 2017.3.1f1, and now using Unity 2017.4.1f1. VSCode updated itself to May 2018 (version 1.24).

@otri
dotnet --version
Look under the extensions tab of VS Code for the extension version
mono --version

Ok, got it..
VS code C# extension 1.15.2

~ $ dotnet --version
2.1.4
~ $ mono --version
Mono JIT compiler version 5.10.1.47 (2017-12/8eb8f7d5e74 Fri Apr 13 20:18:12 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)

With VS Code C# 1.15.2, dotnet 2.1.4 but Mono 5.8.1 it was still refusing to work for me, however updating mono to 5.10.1.x immediately fixed it! 馃帀

Thanks for the tip off, @otri!

@otri Thanks! @bengsfort I'm glad that configuration worked for you!

Unity 2017, Mac OS... solution for me was to upgrade Mono.

Getting it too with Code 1.27.2. Tried upgrading mono but it had no effect. Started out intermittent and now it appears to happen every time. Coincident with code formatting not working any more. Thinking about switching back to VS Community. Did that help anybody?

I'm closing this issue as the original problem seems to have been resolved.
@rmenapaceJC Can you please

  • File a new issue
  • Include your omnisharp log as well as output from dotnet --version and mono --version
    Thanks!

@DustinCampbell I'm running VScode on Arch Linux and having this same issue as well but in the log it is running OmniSharp.exe which based on your comment is expected however I still get this warning:

[warn]: OmniSharp.MSBuild.ProjectManager
Unable to resolve assembly '/home/brogan/rugby-unity/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'

and the OmniSharp flame icon is red.
On the up side though, everything seems to be working fine at surface level. I have intellisense and code lens.

I have currently installed:
mono --version 5.14.0
dotnet --version 2.1.403
mbuild --version 15.1.8.0
/bin/bash -c 'uname -s -m' Linux x86_64

any help is much appreciated. Thanks.

[EDIT] In writing this I realised I have an error when doing the ms-build --version command. I get

MSBUILD : error MSB1001: Unknown switch.
Switch: --version

so it might be related to that because OmniSharp seems to be running fine. Like it is use-able.

Was this page helpful?
0 / 5 - 0 ratings