Solvedomnisharp vscode Could not find document for file, Omnisharp not working

Issue Description

I recently started a new Unity project, and for the first few days of me working on it, the C# extension had no issues. However, a few days after, all Omnisharp functions stopped working, like reference counters and autocomplete. I checked the logs and found that any time I was typing something, this was showing up:

[info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
        Could not find document for file e:\Games\UnityProjects\Protista\Assets\Scripts\Board.cs

I've tried restarting the server via the command palette multiple times and it hasn't worked.
I tried looking online for solutions and came across this: #4181 (comment) so I set the path to latest in my settings, which is why I have the beta. (Having the beta didn't fix it and it didn't work before I had the beta too.) I also saw this in the changelog on the extension store:

For Mono-based development (e.g. Unity) that requires full .NET framework, you need to set "omnisharp.useGlobalMono": "always". The current value of "auto" will remain "never" until Mono upgrades their bundled MSBuild version.

So I tried setting the "useGlobalMono" to "always", but that didn't work either. I've asked some people on Reddit for help, but nothing worked there either. I've tried uninstalling and reinstalling the extension, also to no avail.

Note: for the most part I am new to development in C#, and this may be a stupid question, but is there supposed to be a .csproj or .sln file somewhere in the directory created by Unity, because I can't find any, and that may be the problem, but I've tried and I can't find anything about it.

Steps to Reproduce

Unknown, Omnisharp was working fine one day then stopped working the next day without any warning.

Expected Behavior

When typing, suggestions that are related to my variables and methods show up, red underlining when there is a syntax error, reference counters, go to definition would do something, etc.

Actual Behavior

None of the above show up, I get no red lines from syntax errors, no reference counters, go to definition does nothing, and the only suggestions I get when typing is based on words that have already appeared in my script.

Logs

OmniSharp log

Starting OmniSharp server at 1/10/2021, 2:40:37 PM Target: e:\Games\UnityProjects\Protista

OmniSharp server started.
Path: c:\Users\jagsh.vscode\extensions\ms-dotnettools.csharp-1.23.8.omnisharp\1.37.6-beta.23\OmniSharp.exe
PID: 4092

Starting OmniSharp on Windows 6.2.9200.0 (x64)
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 16.8.0 - "c:\Users\jagsh.vscode\extensions\ms-dotnettools.csharp-1.23.8.omnisharp\1.37.6-beta.23.msbuild\Current\Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to 'c:\Users\jagsh.vscode\extensions\ms-dotnettools.csharp-1.23.8.omnisharp\1.37.6-beta.23.msbuild\Current\Bin\MSBuild.exe'
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 16.8.0 - "c:\Users\jagsh.vscode\extensions\ms-dotnettools.csharp-1.23.8.omnisharp\1.37.6-beta.23.msbuild\Current\Bin"
CscToolExe = csc.exe
CscToolPath = c:\Users\jagsh.vscode\extensions\ms-dotnettools.csharp-1.23.8.omnisharp\1.37.6-beta.23.msbuild\Current\Bin\Roslyn
MSBuildExtensionsPath = c:\Users\jagsh.vscode\extensions\ms-dotnettools.csharp-1.23.8.omnisharp\1.37.6-beta.23.msbuild
MSBuildToolsPath = c:\Users\jagsh.vscode\extensions\ms-dotnettools.csharp-1.23.8.omnisharp\1.37.6-beta.23.msbuild\Current\Bin
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'e:\Games\UnityProjects\Protista'.
info: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
info: OmniSharp.MSBuild.ProjectSystem
No solution files found in 'e:\Games\UnityProjects\Protista'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'e:\Games\UnityProjects\Protista'.
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 'e:\Games\UnityProjects\Protista' on host 22020.
info: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
Could not find document for file e:\Games\UnityProjects\Protista\Assets\Scripts\Board.cs

C# log

Getting latest OmniSharp version information Downloading package 'Latest OmniSharp Version Information' (1 KB).................... Done! In this case, even though I'd done it before, I tried uninstalling and reinstalling the C# extension as a last-ditch effort.

Environment information

VSCode version: 1.52.1
C# Extension: 1.23.8

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.101 Commit: b377529961

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.101\

Host (useful for support):
Version: 3.1.1
Commit: a1388f194c

.NET Core SDKs installed:
3.1.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
anaconda-extension-pack ms-python 1.0.1
csharp ms-dotnettools 1.23.8
debugger-for-chrome msjsdiag 4.12.11
discord-vscode icrawl 4.1.0
java redhat 0.73.0
jupyter ms-toolsai 2020.12.414227025
python ms-python 2020.12.424452561
remote-containers ms-vscode-remote 0.154.2
remote-ssh ms-vscode-remote 0.62.0
remote-ssh-edit ms-vscode-remote 0.62.0
remote-wsl ms-vscode-remote 0.52.0
unity-debug Unity 3.0.2
unity-tools Tobiah 1.2.12
vscode-java-debug vscjava 0.30.0
vscode-java-dependency vscjava 0.16.0
vscode-java-pack vscjava 0.12.1
vscode-java-test vscjava 0.27.0
vscode-maven vscjava 0.27.1
vscode-pull-request-github GitHub 0.22.0
vscode-pylance ms-python 2021.1.0
vscode-remote-extensionpack ms-vscode-remote 0.20.0
vscode-yaml redhat 0.13.0
vscodeintellicode VisualStudioExptTeam 1.2.10
21 Answers

✔️Accepted Answer

yeah but now it picks up the correct MSBuild which is good

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Build Tools 2019 16.8.30804.86 - "E:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"

so what you need to do now, is follow the link in the error and install .NET 4.7.1 developer pack (https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net471-developer-pack-offline-installer)

Other Answers:

oh, I did not notice that you are on Windows. Then Mono has no effect.

You need to install VS 2019 Build Tools https://visualstudio.microsoft.com/de/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16 or VS 2019 https://visualstudio.microsoft.com/de/thank-you-downloading-visual-studio/?sku=Community&rel=16

Then Omnisharp will pick up the MSBuild that comes with that.

Related Issues:

99
omnisharp vscode v1.23.1 fails to load Unity project, worked with v1.23.0
The problem is that the new .NET Core 3.1 SDK isn't supported by any current Mono release ...
69
omnisharp vscode [fail]: OmniSharp.MSBuild.ProjectManager: Attemped to update project that is not loaded.
Thanks a bunch! This solved the issue for me Steps taken Download version 1.15.2 (see link above ...
50
omnisharp vscode Debug Console window cannot accept Console.ReadLine() input during debugging
From @kieferrm on December 17 2016 14:50 The debug console is output only From @LiangZugeng on Decem...
31
omnisharp vscode 'System' not found after update to dotnet core 3.0
I was able to resolve this issue by uninstalling mono via brew and letting omnisharp use the MSBuild...
31
omnisharp vscode Omnisharp can't find .NET SDK when open any C sharp project
Sometimes the Visual Studio warning will still persist even after installing the .NET SDK ...
28
omnisharp vscode Debug multiple ASP.NET Core projects in Visual Studio Code
Try this also Moved from microsoft/vscode#25628 From @mdmoura VSCode Version: 1.11.2 OS Version: Win...
28
omnisharp vscode The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.
Solved this problem by adding omnisharp.json with Was asked to create new issue on #2876 Environment...
27
omnisharp vscode Format code returns: Sorry, but there is no formatter for 'csharp'-files installed.
Ah got it there was line csharp.format.enable: false in my user config after cleared that it started...
26
omnisharp vscode Issues when upgrading to 1.23.3 - Unity assembly definitions not found correctly
A temporary work-around to anyone who finds this for now: Right-click the C# extention from within V...
25
omnisharp vscode Always show "Downloading package 'OmniSharp (.NET 4.6 / x64)' (12310 KB) ."
Sorry for the delay I needed to get 1.6 out the door before taking some time to write up the steps b...
22
omnisharp vscode The SDK 'Microsoft.NET.Sdk.Web' specified could not be found
Latest OmniSharp beta as of now is 3.5.0-beta.2204 which seem to work with the latest .NET Core SDK ...
20
13
omnisharp vscode remove unused usings
Bump!.. This reasonably basic capability is a big miss on Visual Studio Code Environment data dotnet...
11
omnisharp vscode Problem after update to .NET SDK 2.2.202-1
For anyone trying to fix this quickly: which is followed by the list of versions $ sudo apt install ...
11
omnisharp vscode Omnisharp.msbuild.projectmanager - failed to load project file - no IntelliSense
I'm stuck on this issue with Ubuntu 19.04 I tried setting omnisharp.useGlobalMono: never (for those ...
11
omnisharp vscode C# Extension fails only for netcoreapp3.0 GA
Guys I've got the solution (for those who don't want to install VS2019) Go to Microsoft VS downloads...
9
omnisharp vscode The SDK 'Microsoft.NET.Sdk' specified could not be found.
Don't ask me where I found this Couldn't get the (latest) C# extension to work correctly on one of m...
5
omnisharp vscode Errors when building solution which contains both C# .csproj and F# .fsproj projects.
I just wanted to let everyone here know that I just released on a new beta of C# for VS Code that sh...
5
omnisharp vscode Could not find document for file, Omnisharp not working
yeah but now it picks up the correct MSBuild which is good so what you need to do now ...
4
omnisharp vscode Crash: 'Debug adapter process has terminated unexpectedly' on arch and manjaro
So apparently the wrong version of icu is expected ArchLinux has icu 58 Environment data dotnet --in...
4
omnisharp vscode Cannot download OmniSharp behind proxy/firewall
This worked for me (in VS Code settings file): From @TheBlueSky on July 18 2016 4:37 Hello everyone ...
3
omnisharp vscode Debugging f# on .net core
@gregg-miskelly @DustinCampbell as a note thx a lot for support ref ionide/ionide-vscode-fsharp#366 ...
3
omnisharp vscode Intellisense no longer working on C# files
This worked for me Environment data dotnet --info output: VS Code version: 1.16.1 64 bit C# Extensio...
124
efcore No executable found matching command "dotnet-ef" even after adding CLI
I has this issue and like to share I want to Migrate my Database with Models I am using EF Core 2.0 ...
116
efcore UseSqlServer() method is missing from Microsoft.EntityFrameworkCore.SqlServer 1.1.1
Hm - try manually adding the using statement using Microsoft.EntityFrameworkCore; and building again...
63
xunit .NET Core tests produce no output
After some exploration I figured out an easy solution: dotnet test --logger:console;verbosity=detail...
60
efcore How to write DbFunction's translation?
@Kation You actually does not need so much of code to use JSON_VALUE function Based on documentation...
58
efcore Inheritance problem with DbContext subclasses requiring constructor to supply DbContextOptions<DerivedContext>
I was able to resolve this without a hack by providing a protected constructor that uses DbContextOp...
50
efcore MissingMethodException: Method not found: 'Boolean Microsoft.EntityFrameworkCore.Migrations.IMigrationsModelDiffer.HasDifferences
@AmSmart just to clarify in the documentation that @ajcvickers mentioned it gives updated code for t...
47
efcore error NU1202: Package dotnet-ef 3.0.1 is not compatible with netcoreapp3.0
@bricelam Presumably the workaround for anyone hitting this is to install the 3.0.0 version explicit...
42
efcore Could not load System.Diagnostics.DiagnosticSource
Looks like this only occurs on Class Library projects targeting netcoreapp1.1 Could not load file or...
39
efcore EF7 (RC1) - Cannot Skip() and Take() in SQL Server 2008
@tobbylee1 This API now uses a nested closure pattern: I am aware that SQL Server 2012 and above has...
36
ImageSharp WebP Support
I am working on support for webp So far decoding of lossless images is almost done I will continue w...
33
efcore Problem with dotnet cli ef tools after upgrading to vs 2017 15.4.4 and november .net core rollup
I have the same predicament Error is occurring when running: dotnet ef migrations remove I was able ...
29
efcore The instance of entity type cannot be tracked because another instance with the same key value for {'Id'} is already being tracked
Numerous issues I've been running into have one nasty root In a nutshell: I've learned the hard way ...
28
efcore Cannot be tracked because another instance of this type with the same key is already being tracked
@rickco75 I had same issue and get rid of it by below: In your case it will be: var record2 = _conte...
26
language ext FP design with language-ext
@andyigreg I have talked about this before with Free Monads and you can see the working in the Accou...
23
efcore Could not load file or assembly System.ComponentModel.Annotations, Version=4.2.0.0
In some form this problem is already there for more then two years Hi the past few days I tried to g...
23
efcore Significant Query Slowdown When Using Multiple Joins Due To Changes In 3.0
I would like to chime in and say that we are also having this issue and is very problematic for us ...
22
efcore pluggable schemes for mapping c# names
update for efcore3 the Relational() methods have been removed in 469177a I am using EF Core with Pos...
20
efcore Distinguish cancellation from failure to allow different logging strategies
I think this should have a label urgent-fix not consider-for-next-release What problem are you tryin...
18
Newtonsoft.Json Serialization of decimals does not respect precision
I agree that this is unexpected behaviour at the very least and imho it is also a bug For 15 the pre...
18
Entitas CSharp Roslyn based code generator
Wooooot! Just generated the very first time! The current code generator relies on reflection which m...
17
GitVersion GitVersion on VSTS fails with hosted macOS and Linux agents
Under macOS (10.14) Since version 4.0.0 of GitVersion it seems to be supported to use the GitVersion...
16
language ext How do I use Try<T> with an existing method?
Anyone able to help me out here? Sorry if this is a dumb question but as I said I'm fairly new to FP...
15
efcore Mechanism/API to specify a default conversion for any property of a given type in the model
For EF Core 6.0.0-preview6: Value conversions were introduced by #242 Currently conversions are only...
15
efcore SQL Server Migrations: Idempotent scripts fails with 'invalid column name' (needs EXEC)
Hi Another workaround is to globally wrap SQL scripts with EXECUTE() statement I have encountered a ...
15
efcore Discussion for announcement: EF Core 2.0: design-time DbContext discovery changes
@markrendle After discussing with Hosting it sounds like Startup.Configure() should only be used to ...
14
choco PHP Package won't upgrade or uninstall - Path Bind Error
@jansohn only workaround that I know of currently is: Uninstall the package without running the unin...