omnisharp-roslyn: Omnisharp does not find Unity3D assemblies
Hello,
I am trying to get Omnisharp to work with a Unity3D project on GNU/Linux (Kubuntu 20.04). My editor is Neovim 0.5 (pre-release) which includes its own LSP client. Neovim downloaded the latest Omnisharp release (1.37.1). The server is working, I am getting diagnostic messages, documentation and code completion, but it acts as if it does not know anything about Unity.
mono --versionshows 6.8.0.105 for the globally installed Mono- The launch command used by Neovim is
~/.cache/nvim/nvim_lsp/omnisharp/run --languageserver --hostPID <PID of Neovim process>
I would assume that Omnisharp uses its bundled Mono. How can I get Omnisharp to produce log files, and where can I find them?

About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 31 (10 by maintainers)
.NET 6.0 build of OmniSharp does not support Unity.
@harrisonmg I had better luck by avoiding the run script entirely, I tried to mess with it quite a bit like you did. Here is the way I setup the server with nvim, instead of calling the run script I call omnisharp using global mono directly.
Go to
/usr/lib/monoand check what the latest version you have, then setFrameworkPathOverrideto point to that folder.For me it’s worked setting it to both
/usr/lib/mono/4.5and/usr/lib/mono/4.8-api.Thank you everyone for your input. To summarize, the issue is that the bundled Mono cannot find any 3rd party assemblies at all. It is the responsibility of the client to start the server with a global Mono installation. I have for now modified the
runscript to change one variable:That way when the
runscript starts the server ("${mono_cmd}" "${omnisharp_cmd}" "$@") it will useusr/bin/monoas the Mono binary.Now the next question is how to tell the server which Mono to use. From looking at the
runscript there does not appear to be any way of passing a command-line option or environment variable to the script. So I figure the best course of action would be to forego therunscript altogether and just invokemonoandomnisharpdirectly. From the looks of it the script does not really do much anyway.Is this the correct way? From what I can understand the VS Code plugin does the same. Please correct me if I’m wrong, I don’t actually know TypeScript, so I’m just taking an educated step.
Thanks, but no dice. I don’t know what else I could be doing wrong. I’m using the Mono build of OmniSharp mentioned by @nyngwang and mono 6.8.0.105 (though 6.12.0.147 also didn’t work).
I still get a load of
messages until the server eventually initializes after an unacceptably long few minutes (perhaps because of all the
type or namespace not founderrors?)This is driving me nuts.
The Mono build of OmniSharp, but started with global Mono installation from your machine (not the lightweight Mono OmniSharp ships with).
I still get the same issue that MonoBehaviour and other Unity types cannot be found. Even with the fix that @HiPhish gave.
I’m having the same issue as @HiPhish, omnisharp with neovim LSP. Omnisharp works but acts like all Unity related things don’t exist. This thread was helpful but didn’t get me all the way home. My details:
mono: 6.12.0.147 msbuild: 16.10.1 omnisharp run script:
The only thing in my
lsp.logis a bunch ofuntil the server initializes after a number of minutes.
Anything else I can try? Thanks!
EDIT: Also, I’ve manually generated .csproj files through the Unity editor for the following categories: embedded packages, local packages, registry packages, and built-in packages. I’ve experimented with other combinations to no avail.
@HiPhish Thanks!
Mono binaries on latest MacOS’s are installed elsewhere… Thought I post it here as it could be of any help for others.
Note: Unity doesn’t generate .sln and .csproj files. So for Neovim you have to create them yourself, in case of new projects. Or open a .cs file in VS or Rider and let them auto generate it for you.
Hi I’m on Windows using nvim lspconfig omnisharp language server. It doesn’t recognize the assemblies as well. When loading a basic script it says that it couldn’t find monobehavior class
@axelson That’s a VSCode setting, regarding how the OmniSharp-roslyn process is started.
I will close this because at the end, this is by design - OmniSharp doesn’t ship with reference assemblies for .NET Framework. we will add a better error message in https://github.com/OmniSharp/omnisharp-roslyn/issues/2029 so that it’s clear that full Mono is needed when reference assemblies are not found
ah that could be - not every mono distro has MSBuild bundled
@nickspoons there is a setting
omnisharp.useGlobalMonowhich can be set toalways. It then uses global Mono form the PATH to start OmniSharp.exe process. Additionally a custom path can be provided too. https://github.com/OmniSharp/omnisharp-vscode/blob/97768562a4f950db687d5d9314da4a854c9e6f4c/src/omnisharp/launcher.ts#L264-L277@snowgoon88 if you have trouble with VS Code, please open an issue in https://github.com/OmniSharp/omnisharp-vscode and provide your OmniSharp log with
omnisharp.logginglevel: "debug"enabled.When OmniSharp starts on its own embedded Mono it will have no reference assemblies for desktop …NET and Unity and other non-.NET Core development won’t work or be limited.
In VS Code there is a setting to start OmniSharp on global Mono instead and that allows full compatibility with all desktop .NET development. I would imagine in this case a setting like this is needed too.
However, I don’t think this is an issue for OmniSharp itself as it already provides the necessary tools for achieving this - it’s just the client must make the decisions, therefore I would recommend to move this issue to the client implementation(s).