Omnisharp-vscode: C# extension fails to load on my mac (Could not load file or assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies)

Created on 22 Apr 2018  路  4Comments  路  Source: OmniSharp/omnisharp-vscode

Environment data

dotnet --info output:
.NET Command Line Tools (2.1.105)
Product Information:
Version: 2.1.105
Commit SHA-1 hash: 141cc8d976
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.13
OS Platform: Darwin
RID: osx.10.13-x64
Base Path: /usr/local/share/dotnet/sdk/2.1.105/
Microsoft .NET Core Shared Framework Host
Version : 2.0.7
Build : 2d61d0b043915bc948ebf98836fefe9ba942be11

VS Code version:
February 2018 (version 1.21)

C# Extension version:
1.14.0 (February 14, 2017)

Steps to reproduce

First launch of a dotnet console app (Hello world) : https://code.visualstudio.com/docs/other/dotnet

Expected behavior

When the project folder is first opened in VS Code, a notification should appear at the top of the window asking to add the required assets to build and debug your project.

Actual behavior

C# extension fails to load with an error:
Some projects have trouble loading. Please review the output for more details.

Starting OmniSharp server at 2018-4-21 18:52:39
    Target: /Users/xxx/Documents/dotnet

OmniSharp server started wth Mono
    Path: /Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/run
    PID: 12663

锘縖info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.13.4 (x64)
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 15.0 - "/Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin"
[fail]: OmniSharp.Services.AssemblyLoader
        Failed to load assembly from path: /Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin/Microsoft.Build.dll
System.BadImageFormatException: 
File name: '/Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin/Microsoft.Build.dll'
  at (wrapper managed-to-native) System.Reflection.Assembly:LoadFrom (string,bool)
  at System.Reflection.Assembly.LoadFrom (System.String assemblyFile) [0x00000] in <c9f8153c41de4f8cbafd0e32f9bf6b28>:0 
  at OmniSharp.Services.AssemblyLoader.LoadFrom (System.String assemblyPath, System.Boolean dontLockAssemblyOnDisk) [0x0003b] in <4cf1f6f621fc416d82d0ddd5c560b7fa>:0 
[fail]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Could not find MSBuild executable path.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 15.0 - "/Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin"
            MSBuildExtensionsPath = /Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild
            CscToolPath = /Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
            MSBuildToolsPath = /Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/xxx/Documents/dotnet'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in /Users/xxx/Documents/dotnet
[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
        No solution files found in '/Users/xxx/Documents/dotnet'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/xxx/Documents/dotnet/dotnet.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/xxx/Documents/dotnet'.
[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/xxx/Documents/dotnet' on host 12644.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/xxx/Documents/dotnet/dotnet.csproj
[fail]: OmniSharp.Services.AssemblyLoader
        Failed to load assembly from path: /Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin/Microsoft.Build.dll
System.BadImageFormatException: 
File name: '/Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin/Microsoft.Build.dll'
  at (wrapper managed-to-native) System.Reflection.Assembly:LoadFrom (string,bool)
  at System.Reflection.Assembly.LoadFrom (System.String assemblyFile) [0x00000] in <c9f8153c41de4f8cbafd0e32f9bf6b28>:0 
  at OmniSharp.Services.AssemblyLoader.LoadFrom (System.String assemblyPath, System.Boolean dontLockAssemblyOnDisk) [0x0003b] in <4cf1f6f621fc416d82d0ddd5c560b7fa>:0 
[fail]: OmniSharp.Services.AssemblyLoader
        Failed to load assembly from path: /Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin/Microsoft.Build.dll
System.BadImageFormatException: 
File name: '/Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/.omnisharp/omnisharp/msbuild/15.0/Bin/Microsoft.Build.dll'
  at (wrapper managed-to-native) System.Reflection.Assembly:LoadFrom (string,bool)
  at System.Reflection.Assembly.LoadFrom (System.String assemblyFile) [0x00000] in <c9f8153c41de4f8cbafd0e32f9bf6b28>:0 
  at OmniSharp.Services.AssemblyLoader.LoadFrom (System.String assemblyPath, System.Boolean dontLockAssemblyOnDisk) [0x0003b] in <4cf1f6f621fc416d82d0ddd5c560b7fa>:0 
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/Users/xxx/Documents/dotnet/dotnet.csproj'.
/Users/xxx/Documents/dotnet/dotnet.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.ProjectManager+<>c__DisplayClass22_0.<LoadProject>b__0 () [0x00000] in <fa56b474df684beea44079480e5bc4d2>:0 
  at (wrapper delegate-invoke) System.Func`1[System.ValueTuple`2[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray`1[OmniSharp.MSBuild.Logging.MSBuildDiagnostic]]]:invoke_TResult ()
  at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject (System.String projectFilePath, System.Func`1[TResult] loadFunc) [0x0001b] in <fa56b474df684beea44079480e5bc4d2>:0 

Most helpful comment

@shcodes11 Seems there is some issue with the MSBuild folder. Can you delete the .omnisharp folder and the install.Lock file in the folder - /Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/ and then restart vscode.

All 4 comments

@shcodes11 Seems there is some issue with the MSBuild folder. Can you delete the .omnisharp folder and the install.Lock file in the folder - /Users/xxx/.vscode/extensions/ms-vscode.csharp-1.14.0/ and then restart vscode.

@akshita31 That worked. Thanks for the help.

Not worked it for me.. I tried to removed it this file and the error still appear in my VS Code....

image

@akshita31 could you help me to discover what's going on here ?

@glaucia86 Could you post the output from the Omnisharp log window as you have posted above ?

Was this page helpful?
0 / 5 - 0 ratings