Omnisharp-vscode: Failing to Load Unity Project File

Created on 8 Nov 2017  路  15Comments  路  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:     linuxmint
 OS Version:  18.1
 OS Platform: Linux
 RID:         linuxmint.18.1-x64
 Base Path:   /usr/share/dotnet/sdk/2.0.2/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version:

Version 1.17.2
Commit b813d12980308015bcd2b3a2f6efa5c810c33ba5
Date 2017-10-16T13:57:00.652Z
Shell 1.7.7
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

Mono Version

Mono JIT compiler version 5.4.0.201 (tarball Fri Oct 13 21:51:45 UTC 2017)
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 (concurrent by default)

C# Extension version:

1.13.0

Unity Version (download at http://beta.unity3d.com/download/ee86734cf592/unity-editor_amd64-2017.2.0f3.deb):

2017.2.0f3 Personal

Steps to reproduce

  • Create a Unity 2D project
  • Set code to be External Script Editor

    • Go to Edit > Preferences.



      • Go to External Tools tab and change the External Script Editor using the Browse... option





        • Select /usr/bin/code/






  • Back in Unity, create a C# script asset
  • Double click on script

Expected behavior

C# Intellisense to work.

Actual behavior

C# Intellisense doesn't work. Here is my OmniSharp Log output:

Starting OmniSharp server at 11/8/2017, 12:45:30 PM
    Target: /home/dhicks/Dropbox/unity_class/Text101/Text101.sln

OmniSharp server started wth Mono
    Path: /home/dhicks/.vscode/extensions/ms-vscode.csharp-1.13.0/.omnisharp/omnisharp/OmniSharp.exe
    PID: 20320

锘縖info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Mono 15.0 - "/usr/lib/mono/msbuild/15.0/bin"
            2: StandAlone 15.0 - "/home/dhicks/.vscode/extensions/ms-vscode.csharp-1.13.0/.omnisharp/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Mono 15.0 - "/usr/lib/mono/msbuild/15.0/bin"
            CscToolPath = /home/dhicks/.vscode/extensions/ms-vscode.csharp-1.13.0/.omnisharp/omnisharp/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/home/dhicks/Dropbox/unity_class/Text101'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in /home/dhicks/Dropbox/unity_class/Text101
[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.MSBuildProjectSystem
        Detecting projects in '/home/dhicks/Dropbox/unity_class/Text101/Text101.sln'.
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Loading project: /home/dhicks/Dropbox/unity_class/Text101/Assembly-CSharp.csproj
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
        Failed to load project file '/home/dhicks/Dropbox/unity_class/Text101/Assembly-CSharp.csproj'.
/home/dhicks/Dropbox/unity_class/Text101/Assembly-CSharp.csproj(1,1)
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
File name: 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
  at OmniSharp.MSBuild.MSBuildProjectSystem.LoadProject (System.String projectFilePath) [0x00038] in <b33b7bcd685c4ae4bb5069e4d26c1bf0>:0 

[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/home/dhicks/Dropbox/unity_class/Text101'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Stdio.Program
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Stdio.Program
        Configuration finished.
[info]: OmniSharp.Stdio.Program
        Omnisharp server running using Stdio at location '/home/dhicks/Dropbox/unity_class/Text101' on host 20231.

What I have tried.

  • Updating to the latest version of Mono (http://www.mono-project.com/download/)
  • Updateing to the latest version of dotnet (https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.2-sdk-download.md)
  • Loading the .csproj file outside of Unity.
  • Using the VSCode asset in Unity
  • Disabling and Enabling the C# plugin in vscode.
Bug Resolved-Fixed Unity

Most helpful comment

Hmmm... it seems that Microsoft.Build.dll simply doesn't exist. That's very strange if you installed both mono-devel and mono-complete. However, that would also explain the problem. I would also assume that running msbuild at the command-line would fail.

I believe there's a separate msbuild package for Debian environments that Mono provides. I would have expected it to be installed with the mono packages you installed, but maybe there's an issue. Try installing msbuild via apt-get.

All 15 comments

Thanks for all of the detail. I'm creating a VM right now to take a look.

@DustinCampbell Great! I honestly think it has something to do with the .sln or the .csproj files that Unity generates, but I can't be sure.

One thing to quickly check -- could you list the contents of /home/dhicks/.vscode/extensions and let me know if there are multiple ms-vscode.csharp versions or just a single one.

$ ls ~/.vscode/extensions | grep csharp
ms-vscode.csharp-1.13.0

Thanks I've seen situations where old extension versions where left behind and loaded incorrectly by VS Code.

Another thing to check: does the file, /usr/lib/mono/msbuild/15.0/bin/Microsoft.Build.dll exist?

Also, which mono package did you install? mono-devel?

$ ls -a /usr/bin/mono/msbuild/15.0/bin
.  ..  Roslyn

Microsoft.Build.dll doesn't exists :/ I installed both mono-devel and mono-complete. Here is the output of the Roslyn folder:

$ ls -a /usr/bin/mono/msbuild/15.0/bin/Roslyn
.               csi.rsp                                      Microsoft.CodeAnalysis.dll            System.Collections.Immutable.dll
..              Microsoft.Build.Tasks.CodeAnalysis.dll       Microsoft.CodeAnalysis.Scripting.dll  System.Reflection.Metadata.dll
csi.exe         Microsoft.CodeAnalysis.CSharp.dll            Microsoft.CSharp.Core.targets         VBCSCompiler.exe
csi.exe.config  Microsoft.CodeAnalysis.CSharp.Scripting.dll  Microsoft.VisualBasic.Core.targets    VBCSCompiler.exe.config

Hmmm... it seems that Microsoft.Build.dll simply doesn't exist. That's very strange if you installed both mono-devel and mono-complete. However, that would also explain the problem. I would also assume that running msbuild at the command-line would fail.

I believe there's a separate msbuild package for Debian environments that Mono provides. I would have expected it to be installed with the mono packages you installed, but maybe there's an issue. Try installing msbuild via apt-get.

It is super weird, I agree. No idea what happened. Okay, I ran sudo apt install msbuild.

Here is my folder now:

$ ls -a /usr/bin/mono/msbuild/15.0/bin
.                                        Microsoft.Common.overridetasks                 Microsoft.WinFx.targets
..                                       Microsoft.Common.targets                       Microsoft.WorkflowBuildExtensions.targets
Extensions                               Microsoft.Common.tasks                         Microsoft.Xaml.targets
Microsoft.Build.CommonTypes.xsd          Microsoft.CSharp.CrossTargeting.targets        MSBuild.dll
Microsoft.Build.Core.xsd                 Microsoft.CSharp.CurrentVersion.targets        MSBuild.dll.config
Microsoft.Build.dll                      Microsoft.CSharp.Mono.targets                  MSBuild.rsp
Microsoft.Build.Framework.dll            Microsoft.CSharp.targets                       Roslyn
Microsoft.Build.Framework.xml            Microsoft.Data.Entity.targets                  SdkResolvers
Microsoft.Build.Tasks.CodeAnalysis.dll   Microsoft.DotNet.Build.CloudTestTasks.dll      Sdks
Microsoft.Build.Tasks.Core.dll           Microsoft.DotNet.Build.Tasks.dll               System.Collections.Immutable.dll
Microsoft.Build.Tasks.v12.0.dll          Microsoft.DotNet.Build.Tasks.Packaging.dll     System.Diagnostics.Process.dll
Microsoft.Build.Tasks.v4.0.dll           Microsoft.DotNet.VersionTools.dll              System.IO.Compression.dll
Microsoft.Build.Utilities.Core.dll       Microsoft.NETFramework.CurrentVersion.props    System.IO.FileSystem.dll
Microsoft.Build.Utilities.Core.xml       Microsoft.NETFramework.CurrentVersion.targets  System.IO.FileSystem.Primitives.dll
Microsoft.Build.Utilities.v12.0.dll      Microsoft.NETFramework.props                   System.Reflection.Metadata.dll
Microsoft.Build.Utilities.v4.0.dll       Microsoft.NETFramework.targets                 System.Security.Cryptography.Algorithms.dll
Microsoft.Build.xml                      Microsoft.ServiceModel.targets                 System.Threading.Tasks.Dataflow.dll
Microsoft.Cci.Extensions.dll             Microsoft.VisualBasic.CrossTargeting.targets   Workflow.targets
Microsoft.Common.CrossTargeting.targets  Microsoft.VisualBasic.CurrentVersion.targets   Workflow.VisualBasic.targets
Microsoft.Common.CurrentVersion.targets  Microsoft.VisualBasic.Mono.targets
Microsoft.Common.Mono.targets            Microsoft.VisualBasic.targets

That seemed to do the trick! A+

You can definitely close the issue. Thanks, @DustinCampbell, you're the best.

Great! Thanks for the heads up. I'm going to file an issue over in omnisharp-roslyn to make sure we fix this appropriately.

I filed https://github.com/OmniSharp/omnisharp-roslyn/issues/1011 to improve OmniSharp when the msbuild package is not installed.

Was this page helpful?
0 / 5 - 0 ratings