OmniSharp / omnisharp-vim

Vim omnicompletion (intellisense) and more for C#
http://www.omnisharp.net
MIT License
1.72k stars 168 forks source link

Yet another "Could not locate MSBuild" #799

Closed dkaszews closed 2 years ago

dkaszews commented 2 years ago

Yeah, so I'm also having problems with "Could not locate MSBuild", but unlike #791 and #792, setting let g:OmniSharp_server_use_net6 = 1 does not help.

If I set it to use mono instead, I'm getting the same exact error on OmniSharp v1.39.X, but on v1.38.X and older I can see: Loaded server for *.sln in 6.3s which looks promising, but :messages show Failed to load project for all projects in the solution`, probably because they are dotnet-core.

I tried using dotnet-sdk-6.0.302-linux-arm64 and 7.0.100-preview.6.22352.1 that comes with PowerShell-core, both by setting $DOTNET_ROOT and copying/linking to /usr/share/dotnet, no dice.

Main project I'm trying to use is PowerShell-core on .net 7, but also getting the same exact results on vimspector toy project

OS is Ubuntu 22.04 LTS aarch64 on Raspberry Pi 4 Model B Rev 1.2

nickspoons commented 2 years ago

When you let g:OmniSharp_server_use_net6 = 1 did you then reinstall the server? Please share your .vimrc and log :OmniSharpOpenLog.

dkaszews commented 2 years ago

Yeah, I run reinstall after each change, also tried restarting vim and using g:OmniSharp_server_path to point at various versions downloaded manually. I can repro the issue with minimum .vimrc:

call plug#begin()
Plug 'OmniSharp/omnisharp-vim'
call plug#end()          
let g:OmniSharp_server_use_net6 = 1 

Here are the OmniSharp logs, look suspicious to me since DotNetPath finds the exact SDK it recommends on the very next line:

NVIM v0.6.1            

OmniSharp server started.
    Path: /home/dkaszews/.cache/omnisharp-vim/omnisharp-roslyn/OmniSharp
    Target: /home/dkaszews/.local/share/nvim/plugged/vimspector/support/test/csharp/csharp.sln
    PID: 275484

[info]: OmniSharp.Stdio.Host   
        Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
        Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService     
        DotNetPath set to /home/dkaszews/Downloads/dotnet-sdk-6.0.302-linux-arm64/dotnet     
[fail]: OmniSharp.MSBuild.Discovery.Providers.SdkInstanceProvider
        OmniSharp requires the .NET 6 SDK or higher be installed. Please visit https://dotnet.microsoft.com/download/dotnet/6.0 to download the .NET SDK.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 0 MSBuild instance(s)
nickspoons commented 2 years ago

OmniSharp requires the .NET 6 SDK or higher be installed.

If the server can't run on your system then there's not much we can do about it on this side, I'd suggest opening an issue at OmniSharp-roslyn. You can repro by simply running the /home/dkaszews/.cache/omnisharp-vim/omnisharp-roslyn/OmniSharp executable from the command line.

Does dotnet --info report anything useful?

dkaszews commented 2 years ago

dotnet --info says it can find SDKs just fine, I have used it to build couple projects without a problem:

global.json file:
  /home/dkaszews/code/PowerShell/global.json

Host:
  Version:      6.0.7
  Architecture: arm64
  Commit:       0ec02c8c96

.NET SDKs installed:
  6.0.302 [/home/dkaszews/Downloads/dotnet-sdk-6.0.302-linux-arm64/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.7 [/home/dkaszews/Downloads/dotnet-sdk-6.0.302-linux-arm64/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.7 [/home/dkaszews/Downloads/dotnet-sdk-6.0.302-linux-arm64/shared/Microsoft.NETCore.App]

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

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

I did previously run the executable outside vim and saw the same errors, but thought that maybe vim will set some variables or arguments which will fix it. Also, :messages only showed the missing MSBuild error and not SDK, so I thought it got past that error.

Thanks for you help, closing the issue and will open one in the main repo.