OmniSharp / omnisharp-vim

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

Failed to load project: [.csproj files] #726

Closed AndrGutierrez closed 3 years ago

AndrGutierrez commented 3 years ago

I already opened an issue of autocompletion and linting not working in unity projects and I realized that it probably is because of this error

Failed to load project:

it says that about all the .csproj files. Thank you for your time

nickspoons commented 3 years ago

In your other issue I referred you to issue #707, which these issues are duplicates of. Did you try telling OmniSharp-vim to use the mono version of OmniSharp-roslyn, as described in #707?

AndrGutierrez commented 3 years ago

yes, I tried it, it didn't work.

As far as I know that's a mac issue, anyways I tried it but nothing happened

nickspoons commented 3 years ago

No, it's not a Mac issue. OP in issue #707 is using manjaro.

Unity uses .NET Framework, which means you need mono to run it on non-Windows systems.

Please follow the instructions in this comment and then post your log (:OmniSharpOpenLog)

AndrGutierrez commented 3 years ago

I already did, but then I commented the mono line, restarted vim, uncommented the same line and opened the project, it worked PERFECTLY... then I restarted vim to check that it would work a second time and it didn't...

at least I don't have the load files error anymore

here is my log, it is too long, it doesn't have any fail messages

https://raw.githubusercontent.com/AndrGutierrez/omnisharplog/main/log.txt?token=AMO7RFCNB455NWWQZJHJOPDBC5EZ6

nickspoons commented 3 years ago

That link 404s

AndrGutierrez commented 3 years ago

https://github.com/AndrGutierrez/omnisharplog/blob/main/log.txt

nickspoons commented 3 years ago

404.

Is this file in a private repo?

I already did, but then I commented the mono line, restarted vim, uncommented the same line and opened the project, it worked PERFECTLY... then I restarted vim to check that it would work a second time and it didn't...

I don't know how to interpret this. Was it the same project both times? Was there a .csproj and .sln both times (my understanding is that unity creates these on the fly and they are not always available)? The log will tell you this.

  1. Add let g:OmniSharp_server_use_mono = 1 to .vimrc
  2. Restart vim
  3. :OmniSharpInstall
  4. Open project
  5. Verify that :echo g:OmniSharp_server_use_mono outputs 1
  6. Post log
AndrGutierrez commented 3 years ago

yeah, the repository was private, I am stupid, it is public now

nickspoons commented 3 years ago

OK, this looks like the problem:

[dbug]: OmniSharp.CompositionHostBuilder
        .NET SDK requires MSBuild instances version 16.8.0 or higher
[dbug]: OmniSharp.MSBuild.Discovery.Providers.MonoInstanceProvider
        Mono MSBuild could not be used because '/usr/lib/mono/msbuild/Current/bin/Microsoft.Build.dll' does not exist.
[warn]: OmniSharp.MSBuild.Discovery.Providers.MonoInstanceProvider
        It looks like you have Mono 6.4.0 or greater installed but MSBuild could not be found.
Try installing MSBuild into Mono (e.g. 'sudo apt-get install msbuild') to enable better MSBuild support, or upgrade to latest Mono: https://www.mono-project.com/download/stable/.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 17.0.0 - "/home/andres/.cache/omnisharp-vim/omnisharp-roslyn/.msbuild/Current/Bin"
[dbug]: OmniSharp.CompositionHostBuilder
        MSBuild instance StandAlone 17.0.0 scored at 1

Here's what mine looks like:

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Mono 16.10.1 - "/usr/lib/mono/msbuild/Current/bin"
            2: StandAlone 17.0.0 - "/home/nickspoon/.cache/omnisharp-vim/omnisharp-roslyn-mono-1.37.13/.msbuild/Current/Bin"
[dbug]: OmniSharp.CompositionHostBuilder
        MSBuild instance Mono 16.10.1 scored at 2
nickspoons commented 3 years ago

I'm using the mono-msbuild package on arch, give that a go.

AndrGutierrez commented 3 years ago

it worked! but just for autocompletion for some reason the errors like:

The type or namespace name 'UnityEngine' could not be found

keep appearing

nickspoons commented 3 years ago

It's not loading those Unity libraries for whatever reason, there are probably details in the log