I am using OmniSharp in combination with Unity. I was a happy user until recently. But since a couple of versions, the updates are just driving me insane.
Today, I was sitting in a caf茅, trying to work on an important update. OmniSharp did not startup, and I realized this was because it was updating itself in the background -- chewing on my data plan without any confirmation. Not nice.
Then, after the update, the Unity classes in other namespaces (even Unity's) were not recognized anymore. Just like after the last update when I had to rebuild Unity's .sln files to make it work again. But this time, even this trick did not work.
What the heck is going on here? This is really annoying.
BTW: "omnisharp.useGlobalMono" is already set to "always", which had caused me headaches last time.
Here is the log output, just in case:
Starting OmniSharp server at 10/13/2020, 10:16:57 AM
Target: /Users/tom/dev/marble/app/unity.ios/unity.ios.sln
OmniSharp server started with Mono 6.10.0.
Path: /Users/tom/.vscode/extensions/ms-dotnettools.csharp-1.23.3/.omnisharp/1.37.2/omnisharp/OmniSharp.exe
PID: 11879
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on MacOS 10.15.6 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Mono 16.8.0 - "/Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin"
2: StandAlone 16.8.0 - "/Users/tom/.vscode/extensions/ms-dotnettools.csharp-1.23.3/.omnisharp/1.37.2/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Mono 16.8.0 - "/Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin"
CscToolExe = csc.exe
CscToolPath = /Users/tom/.vscode/extensions/ms-dotnettools.csharp-1.23.3/.omnisharp/1.37.2/omnisharp/.msbuild/Current/Bin/Roslyn
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/Users/tom/dev/marble/app/unity.ios'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/Users/tom/dev/marble/app/unity.ios/unity.ios.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/tom/dev/marble/app/unity.ios/BestHTTP.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/tom/dev/marble/app/unity.ios/AssetCleaner.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-Editor-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/tom/dev/marble/app/unity.ios/AssetUsageDetector.Editor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/tom/dev/marble/app/unity.ios'.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/tom/dev/marble/app/unity.ios/BestHTTP.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/tom/dev/marble/app/unity.ios' on host 11829.
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/tom/dev/marble/app/unity.ios/BestHTTP.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/tom/dev/marble/app/unity.ios/BestHTTP.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/tom/dev/marble/app/unity.ios/Assembly-CSharp.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-firstpass.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-firstpass.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-Editor.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-Editor.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/tom/dev/marble/app/unity.ios/AssetCleaner.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/tom/dev/marble/app/unity.ios/AssetCleaner.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/tom/dev/marble/app/unity.ios/AssetCleaner.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-Editor-firstpass.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-Editor-firstpass.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/tom/dev/marble/app/unity.ios/Assembly-CSharp-Editor-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/tom/dev/marble/app/unity.ios/AssetUsageDetector.Editor.csproj
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file '/Users/tom/dev/marble/app/unity.ios/AssetUsageDetector.Editor.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project '/Users/tom/dev/marble/app/unity.ios/AssetUsageDetector.Editor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: BestHTTP
[info]: OmniSharp.MSBuild.ProjectManager
Update project: Assembly-CSharp
[info]: OmniSharp.MSBuild.ProjectManager
Update project: Assembly-CSharp-firstpass
[info]: OmniSharp.MSBuild.ProjectManager
Update project: Assembly-CSharp-Editor
[info]: OmniSharp.MSBuild.ProjectManager
Update project: AssetCleaner
[info]: OmniSharp.MSBuild.ProjectManager
Update project: Assembly-CSharp-Editor-firstpass
[info]: OmniSharp.MSBuild.ProjectManager
Update project: AssetUsageDetector.Editor
sorry that you are experiencing this.
@JoeRobich the only thing that jumps to my head at the moment is this - https://github.com/OmniSharp/omnisharp-roslyn/pull/1971/files could this have caused the issue?
@derwaldgeist could you try installing the latest Mono (6.12) from https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.90.macos10.xamarin.universal.pkg and see if it helps?
Same here(OS Windows). Yesterday everything was working, then Omnisharp updated to 1.23.3 and a big chunk of my assembly-refs are messed up, some are missing some are fine even some Unity ones are missing! I also updated the Unity Visual Studio Code package and tried all the "usual" tricks, rebuild the project files,etc...but this time nothing seems to work.
~Installing latest mono-6.12.0.98 for windows rn...~
[edit] Installed latest mono-6.12.0.98, same results.
[edit] Downgrading to omnisharp 1.23.2 solved all issues for me.
Same here (windows). Downgrading the extension to the previous version at least allows me to continue working.
Same here (macOS 10.15.7, dotnet 3.1.402, mono 6.12.0.90). Seems like all references to assemblies created from assembly definitions cannot be loaded. Downgrading to 1.23.2 fixes the issue.
The missing projects/assemblies appear in the log and seem to be loaded fine.
I do get this error but suspect it's unrelated?
Error Message
{
"Request_seq": 11,
"Command": "/v2/highlight",
"Running": true,
"Success": false,
"Message": "\"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.\\nParameter name: line\\n at Microsoft.CodeAnalysis.Text.LinePosition..ctor (System.Int32 line, System.Int32 character) [0x00004] in <74e762f007514b0991a005183ec8dcb2>:0 \\n at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.Handle (OmniSharp.Models.SemanticHighlight.SemanticHighlightRequest request) [0x00146] in <21b524394a70400a98cab126f107046e>:0 \\n at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler`2[TRequest,TResponse][] handlers, TRequest request) [0x00099] in <b7a537fb16684f62b929137a8d5c0190>:0 \\n at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <b7a537fb16684f62b929137a8d5c0190>:0 \\n at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <b7a537fb16684f62b929137a8d5c0190>:0 \\n at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000e7] in <133e51409c104ca89cc3c92babc13829>:0 \"",
"Body": null,
"Seq": 805,
"Type": "response"
}
Dealing with the same issue. How do you downgrade back to 1.23.2?
EDIT - nevermind, figured it out.
@derwaldgeist could you try installing the latest Mono (6.12)
Will try when I am back home. No chance to download 350mb when on the road.
@derwaldgeist Sorry things aren't working. I don't see anything really unusual in the log. I did notice that it listed your Mono 6.10 install as having MSBuild 16.8 which was a surprise since I thought it shipped with 16.6.
Could you provide a log with your omnisharp loglevel set to debug? This should log how references are added to the loaded projects.
If you want more control over when your extensions update, you can toggle off the automatic updates.

Downgrading has solved the core issue but rebuilding the Library and the .sln files doesn't seem to "uncorrupt" my Unity project. Does anyone have a solution for repairing the project?
@duckies I deleted all .csproj and .sln files and then let Unity to rebuild them. This worked.
Same issue after updating C# extension in VS Code to 1.23.3. 1.23.2 works fine.
My project is not a Unity project. Amusingly, a few other projects work fine.
Here is my log (password: TheFastestAnalyzer):
https://file.io/HQjie8bh6jku
Same issue here, and to reiterate what @markonius said, some projects seem to be fine after this update while others seem to be "corrupted". Attempting to find discrepancies between projects. Possibly some configuration that needs to be regenerated?
Bump to say that I have encountered this issue as well. Notably, my Mono was already at 6.12 installed by VS for Mac.
1.23.4 did not fix the issue, since I thought it is related to #1552 since I have a bunch of analyzer installed.
Same here, 1.23.4 does not fix the issue. As written above, this is on macOS 10.15.7 with dotnet 3.1.402, mono 6.12.0.90 and Unity 2020.1.9f1.
Here's the log with omnisharp log level set to debug:
https://gist.github.com/sttz/efe98ccac57117ebc5273ca838475818
Lots of namespaces and types show up as not found. They are in projects that show up in the log, e.g. UnityEngine.UI.csproj, ch.sttz.core.csproj or LeanCommon.csproj. I didn't notice before but some types in Unity's default Assembly-*.csproj projects also show up as not found.
Got this nasty error and spent a whole afternoon trying to fix it. Somehow setting Unity's 'External Script Editor' option to Visual Studio 2019 fixed the problem for me.
Waiting for the fix. I really don't want to accidentally open Visual Studio when I debug and have the computer freeze for a good minute.
@tghgg I got it workarounded by forcing a down-grade to 1.23.2, deleting the .sln and all .csproj files and let Unity re-build them.
1.23.3 was working and then stopped, not sure why. 1.23.4 didn't fix it. Downgraded to 1.23.2.
@derwaldgeist From investigating this new Unity problem from a repro shared in a different issue. It seems that a recent change to make project loading more correct broke some Unity scenarios because Unity is configuring ProjectReferences to not be referenced. See my comment at https://github.com/OmniSharp/omnisharp-vscode/issues/4113#issuecomment-714726062
Thanks for hinting me to #4113. This is pretty funny. A Unity workaround to workaround bug in OmniSharp became a bug in Unity once the original bug was fixed. Or was it the other way around? :-)
To all watching this, let me quote @ericdrobinson from #4113:
In the meanwhile, the options are:
- Update OmniSharp to latest; stick with v1.1.3 of Unity's "Visual Studio Code Editor" package.
- Update "Visual Studio Code Editor" package to latest; stick with OmniSharp v1.23.2.
Given that VSCode likes to update extensions automatically for us, It's probably best to go with option 1 above and update the Unity side once Unity fixes the issue on their end.
As the maintainer of Unity's VSCode package has indicated they are working on a fix in the comments for #4113. I'm going to mark this as a duplicate and allow #4113 to track this issue.
Agreed.
Most helpful comment
@tghgg I got it workarounded by forcing a down-grade to 1.23.2, deleting the .sln and all .csproj files and let Unity re-build them.