vscode-csharp: Failing to Load Unity Project File

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.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 15 (8 by maintainers)

Most upvoted comments

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

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.