OmniSharp / omnisharp-emacs

Troll coworkers - use Emacs at work for csharp!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.NET v3.5 issues with Emacs 25.3.1 and Unity3D

ijacquez opened this issue · comments

Here are all the versions of Mono installed:

  • 2.11.4
  • 3.12.0
  • 3.12.1
  • 4.3.2
  • 5.8.0

Version of Omnisharp: v1.26.3

*omnisharp-log* buffer shows

[12:23:33] ERROR: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo, The reference assemblies for
framework ".NETFramework,Version=v3.5" were not found. To resolve this, install the SDK or
Targeting Pack for this framework version or retarget your application to a version of the framework
for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from
the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your
assembly may not be correctly targeted for the framework you intend.

I tried to clear the GAC via gacutil. I even cleared the GAC.

Is there anything else worth trying?

I have the same problem. Omnisharp v1.26.3 installed via M-x omnisharp-install-server.

The interesting thing is that omnisharp seems to start fine from the command line in the .emacs.d/cache directory: ./run -s <path-to-solution>. However, using M-x omnisharp-start-omnisharp-server from emacs results in the same error message as above.

Which magic mono bits or paths would I have to twiddle to make it find the framework when run inside emacs? Full log attached.

omnisharp-log.txt

I am not sure what could be wrong here, but here are a couple of options, off my mind..

  • customize the omnisharp-expected-server-version variable to a newer omnisharp server version (the default ATM is "1.26.3") – one of versions from https://github.com/OmniSharp/omnisharp-roslyn/releases, sans the 'v' prefix, e.g. "1.29.1"; and then do M-x omnisharp-install-server to update the server;
  • install MS dotnet core sdk, maybe it has SDK integrated that will be picked by msbuild for your project properly;
  • report an issue to https://github.com/OmniSharp/omnisharp-roslyn/issues as they are maintaining the actual omnisharp server and they might have a better idea what a proper fix would be..

@GroundCombo do you mean you don't get any errors when starting the server from console/terminal, compared to what you get on omnisharp-log?

then the only difference there is (I think) is that omnisharp passes "--encoding utf-8" to the server command line as well.. can you check if starting it from console with --encoding flag breaks it on console too?

./run --encoding utf-8 -s <solution> works fine, omnisharp reads the project without errors and I can see the source files in the log. I assume this has to be some kind of environmental difference between the shell and the Emacs application, but I don't really know what to look for. omnisharp-start-omnisharp-server seems to use the correct script and mono.osx executable.

edit: I also tried installing v1.29.1 - same thing.

can you check those with ps eww $PID ?

Well this looks like another facepalmingly simple issue. $PATH for the emacs process didn't contain any paths with mono executables, so I added /Library/Frameworks/Mono.framework/Versions/Current/Commands to the path and restarted the server; completion works now. Thanks for prodding me in the right direction.

Great! Do you think we should add a warning or something on a mac in omnisharp-emacs? At least a couple of persons tripped on it, might be worth it? Or something like 'M-x omnisharp-doctor'?

Couldn't hurt, I suppose. I don't know how tough it would be to catch the potential gotchas with mono and emacs installations, but checking some common errors would be helpful especially to Unity developers whose exposure to mono might be limited to one-channel audio.
M-x omnisharp-install-server is really nice, though.

Thanks guys. I'll try it out. Wouldn't setting a default path to Mono in run be sufficient?

@ijacquez that script is served by omnisharp-roslyn server binary. I could try to override it in omnisharp-emacs but it is probably better to refer to maintainers of https://github.com/OmniSharp/omnisharp-roslyn

I can confirm that all works. For those looking for a quick fix:

;; For OmniSharp, place this before (require `omnisharp)
(setenv "PATH" (concat (getenv "PATH") ":/Library/Frameworks/Mono.framework/Versions/Current/Commands"))
(setq exec-path (append exec-path '("/Library/Frameworks/Mono.framework/Versions/Current/Commands")))

@ijacquez thanks! will add this note to README.md in the troubleshooting section