Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not locate MSBuild instance to register with OmniSharp. #2635

Open
DarkRRb opened this issue Sep 1, 2024 · 6 comments
Open

Could not locate MSBuild instance to register with OmniSharp. #2635

DarkRRb opened this issue Sep 1, 2024 · 6 comments

Comments

@DarkRRb
Copy link

DarkRRb commented Sep 1, 2024

OmniSharp Log:

D:\.code\CSharp\Demo>"C:\Users\<User>\Downloads\omnisharp.http-win-x64\OmniSharp.exe" -l Trace
trce: OmniSharp.Services.AssemblyLoader[0]
      Assembly loaded: OmniSharp.Cake
dbug: OmniSharp.CompositionHostBuilder[0]
      Loaded OmniSharp.Cake, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader[0]
      Assembly loaded: OmniSharp.DotNetTest
dbug: OmniSharp.CompositionHostBuilder[0]
      Loaded OmniSharp.DotNetTest, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader[0]
      Assembly loaded: OmniSharp.Host
dbug: OmniSharp.CompositionHostBuilder[0]
      Loaded OmniSharp.Host, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader[0]
      Assembly loaded: OmniSharp.MSBuild
dbug: OmniSharp.CompositionHostBuilder[0]
      Loaded OmniSharp.MSBuild, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader[0]
      Assembly loaded: OmniSharp.Roslyn
dbug: OmniSharp.CompositionHostBuilder[0]
      Loaded OmniSharp.Roslyn, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader[0]
      Assembly loaded: OmniSharp.Roslyn.CSharp
dbug: OmniSharp.CompositionHostBuilder[0]
      Loaded OmniSharp.Roslyn.CSharp, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader[0]
      Assembly loaded: OmniSharp.Script
dbug: OmniSharp.CompositionHostBuilder[0]
      Loaded OmniSharp.Script, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
trce: OmniSharp.Services.AssemblyLoader[0]
      Assembly loaded: OmniSharp.Shared
dbug: OmniSharp.CompositionHostBuilder[0]
      Loaded OmniSharp.Shared, Version=1.39.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
info: OmniSharp.Services.DotNetCliService[0]
      Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
info: OmniSharp.Services.DotNetCliService[0]
      DotNetPath set to D:\Portable\dotnet\bin\dotnet
dbug: OmniSharp.CompositionHostBuilder[0]
      .NET SDK requires MSBuild instances version 16.3 or higher
info: OmniSharp.MSBuild.Discovery.MSBuildLocator[0]
      Located 0 MSBuild instance(s)
Could not locate MSBuild instance to register with OmniSharp.

I installed DotNet using the tutorial, I also configured the DOTNET_ROOT environment variable

dotnet --info

D:\.code\CSharp\Demo>dotnet --info
.NET SDK:
 Version:           8.0.303
 Commit:            29ab8e3268
 Workload version:  8.0.300-manifests.c915c39d
 MSBuild version:   17.10.4+10fbfbf2e

运行时环境:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   D:\Portable\dotnet\bin\sdk\8.0.303\

已安装 .NET 工作负载:
没有要显示的已安装工作负载。

Host:
  Version:      8.0.7
  Architecture: x64
  Commit:       2aade6beb0

.NET SDKs installed:
  8.0.303 [D:\Portable\dotnet\bin\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.7 [D:\Portable\dotnet\bin\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.7 [D:\Portable\dotnet\bin\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 8.0.7 [D:\Portable\dotnet\bin\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [D:\Portable\dotnet\bin]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

The above shows that I have an MSBuild 17.10.4+10fbfbf2e

But OnmiSharp cannot detect and use it

@Lexpeartha
Copy link

Lexpeartha commented Sep 2, 2024

Experiencing possibly the same issue, although I get different error message:

OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Failed to handle request initialize 0 - System.InvalidOperationException: Failed to find all versions of .NET Core MSBuild.

Here's what my dotnet --info gives me:

.NET SDK:
 Version:           8.0.401
 Commit:            811edcc344
 Workload version:  8.0.400-manifests.b6724b7a
 MSBuild version:   17.11.4+37eb419ad

Runtime Environment:
 OS Name:     vanilla
 OS Version:  2.0
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/8.0.401/

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.

Host:
  Version:      8.0.8
  Architecture: x64
  Commit:       08338fcaa5

.NET SDKs installed:
  8.0.401 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Even tried overriding DOTNET_MSBUILD_SDK_RESOLVER_* env variables manually, but that didn't help.

@JoeRobich
Copy link
Member

@CwkDark OmniSharp looks for the dotnet CLI to be available from the PATH.

@Lexpeartha Does the folder you are opening have a global.json? If so, what version of the SDK is it pinning?

@Lexpeartha
Copy link

@Lexpeartha Does the folder you are opening have a global.json? If so, what version of the SDK is it pinning?

No, I don't this it has. The only version I have, which would be 8.0.4 I believe.

@JoeRobich
Copy link
Member

@Lexpeartha I found this issue comment that might help. microsoft/MSBuildLocator#302 (comment)

@DarkRRb
Copy link
Author

DarkRRb commented Sep 4, 2024

@CwkDark OmniSharp looks for the dotnet CLI to be available from the PATH.

dotnet CLI is located in PATH

@JoeyGee
Copy link

JoeyGee commented Sep 19, 2024

I got the same issue. I simply downloaded the wrong release (omnisharp-win-x64). As soon as I got the right release (omnisharp-win-x64-net6.0) the msbuild instances for netcore were found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants