Could not find document for file, Omnisharp not working
See original GitHub issueIssue 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: https://github.com/OmniSharp/omnisharp-vscode/issues/4181#issuecomment-742668376 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
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)
DotNetPath set to dotnet
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"
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'
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
Detecting Cake files in 'e:\Games\UnityProjects\Protista'.
Could not find any Cake files
No solution files found in 'e:\Games\UnityProjects\Protista'
Detecting CSX files in 'e:\Games\UnityProjects\Protista'.
Could not find any CSX files
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
Configuration finished.
Omnisharp server running using Stdio at location 'e:\Games\UnityProjects\Protista' on host 22020.
Could not find document for file e:\Games\UnityProjects\Protista\Assets\Scripts\Board.cs
C# log
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: b377529961Runtime 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 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (4 by maintainers)
Top GitHub Comments
yeah but now it picks up the correct MSBuild which is good
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)
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.