-
Notifications
You must be signed in to change notification settings - Fork 420
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
Omnisharp does not find Unity3D assemblies #1948
Comments
My ultimate goal is nearly the same : use emacs+lsp on Unity files. (see #1947) |
Go to For me it's worked setting it to both
|
I have not yet tried this solution (and I will) but.. Everything is here : emacs-lsp/lsp-mode#2188 (comment) |
I have the issue with emacs |
I am afraid I have no experience with Unity. My question is, does vscode manage to do it better, and if they do (and they are by far the most popular client for omnisharp-roslyn IMHO) -- then we can replicate the solutions in |
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). |
How does VSCode do this, @filipw? Is it a command line flag passed to the server? Or are you referring to omnisharp.json settings? |
On VS code (Linux), I tried playing with setting ALWAYS use global mono and setting the path to the global mono (it is done via a .json file) and then restart the server several times (with the command palette of VS code). But it does not work : Unity referenced functions/classes are not recognized. With Emacs (Linux, and my So, I guess the issus is client depend, sadly... |
@nickspoons there is a setting @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 |
Thanks for the help everybody, I tested with emacs and vscode using the |
ah that could be - not every mono distro has MSBuild bundled |
FTR this issue is related: NixOS/nixpkgs#95911 |
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 bin_dir=/usr/bin # Previous value: ${base_dir}/bin That way when the Now the next question is how to tell the server which Mono to use. From looking at the 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. |
For NixOS users I fixed with this: NixOS/nixpkgs#98435, basically, the |
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 #2029 so that it's clear that full Mono is needed when reference assemblies are not found |
Is that setting part of the configuration for omnisharp-roslyn? I don't see it documented on the configuration page: https://github.com/OmniSharp/omnisharp-roslyn/wiki/Configuration-Options Or is it VSCode specific or something else? |
@axelson That's a VSCode setting, regarding how the OmniSharp-roslyn process is started. |
Is there a way of setting this option outside of VSCode as well? Like a command-line parameter, environment variable or configuration file? |
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 |
@HiPhish Thanks! Mono binaries on latest MacOS's are installed elsewhere.. bin_dir=/Library/Frameworks/Mono.framework/Versions/Current/bin 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. |
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
The only thing in my
until 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. |
@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.
|
I still get the same issue that MonoBehaviour and other Unity types cannot be found. Even with the fix that @HiPhish gave. |
@HiPhish @Mathijs-Bakker With dotnet-6.0 since there is no script file |
.NET 6.0 build of OmniSharp does not support Unity. |
Edit: ^ This info turns out to be very helpful for my debugging. And for people who don't know, the [Mono build of OmniSharp] mentioned in the following comment is this one: omnisharp-mono.tar.gz |
The Mono build of OmniSharp, but started with global Mono installation from your machine (not the lightweight Mono OmniSharp ships with). |
@morabitom Thank you so much! This works! I'm on the newest version v1.38.0. |
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 This is driving me nuts. |
@harrisonmg Which Omnisharp release exactly did you install on your computer? Have had a long time not writing C# but I might also check it later. |
Currently I have installed mono version 6.12.0.122 using these instructions and doing Edit: on Ubuntu 20.04.4 LTS, running in WSL Thanks for your help! |
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 --version
shows 6.8.0.105 for the globally installed Mono~/.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?
The text was updated successfully, but these errors were encountered: