Not working with Unity projects
See original GitHub issueIssue Description
Steps to Reproduce
Omnisharp hasn’t been working in VS Code with Unity projects for me for several weeks now (was just burying my head in the sand hoping it was a temporary issue but it doesn’t look like it). It’s affecting multiple Unity projects (all that I’ve tried) for me that used to be supported fine, so I guess there’s been a vscode / omnisharp update that’s changed something - I’m not really sure.
Expected Behavior
When looking at code that compiles in Unity there shouldn’t be lots of compilation errors highlighted.
Actual Behavior
Code that’s known to compile (compiles fine within Unity itself) is showing lots of errors (namely with using some third-party plugins that are copied into the project.
I’ve tried changing my preferences in Unity to make sure it generates csproj file for everything and triggered it to regenerate all projects but don’t see any difference from doing that.
Logs
OmniSharp log
OmniSharp server started. Path: c:\Users\Robert.vscode\extensions\ms-dotnettools.csharp-1.23.5.omnisharp\1.37.3\OmniSharp.exe PID: 10404
Starting OmniSharp on Windows 6.2.9200.0 (x64)
DotNetPath set to dotnet
Located 3 MSBuild instance(s)
1: Visual Studio Community 2019 16.5.30011.22 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
2: Visual Studio Build Tools 2019 16.5.30011.22 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin"
3: StandAlone 16.8.0 - "c:\Users\Robert\.vscode\extensions\ms-dotnettools.csharp-1.23.5\.omnisharp\1.37.3\.msbuild\Current\Bin"
Registered MSBuild instance: Visual Studio Community 2019 16.5.30011.22 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
Detecting Cake files in 'c:\Users\Robert\src\RealFit\unity-rust-plugin-test'.
Could not find any Cake files
Detecting projects in 'c:\Users\Robert\src\RealFit\unity-rust-plugin-test\grpc-unity-deadlock-reproduction.sln'.
Queue project update for 'c:\Users\Robert\src\RealFit\unity-rust-plugin-test\Assembly-CSharp-firstpass.csproj'
Queue project update for 'c:\Users\Robert\src\RealFit\unity-rust-plugin-test\Assembly-CSharp.csproj'
Detecting CSX files in 'c:\Users\Robert\src\RealFit\unity-rust-plugin-test'.
Loading project: c:\Users\Robert\src\RealFit\unity-rust-plugin-test\Assembly-CSharp-firstpass.csproj
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 'c:\Users\Robert\src\RealFit\unity-rust-plugin-test' on host 19800.
Successfully loaded project file 'c:\Users\Robert\src\RealFit\unity-rust-plugin-test\Assembly-CSharp-firstpass.csproj'.
Adding project 'c:\Users\Robert\src\RealFit\unity-rust-plugin-test\Assembly-CSharp-firstpass.csproj'
Loading project: c:\Users\Robert\src\RealFit\unity-rust-plugin-test\Assembly-CSharp.csproj
Successfully loaded project file 'c:\Users\Robert\src\RealFit\unity-rust-plugin-test\Assembly-CSharp.csproj'.
Adding project 'c:\Users\Robert\src\RealFit\unity-rust-plugin-test\Assembly-CSharp.csproj'
Update project: Assembly-CSharp-firstpass
Update project: Assembly-CSharp</details>
C# log
The ‘C#’ log tab is empty in VS Code
Here’s just one example of the kind of error I’m seeing in my code because it’s not handling the project’s dependency on a UniTask plugin that’s embedded in the project…
At the top of the file where there’s an appropriate using
directive like using Cysharp.Threading.Tasks;
which should bring in the UniTask
type I get this error:
The type or namespace name 'Cysharp' could not be found (are you missing a using directive or an assembly reference?) [Assembly-CSharp, Assembly-CSharp]
The later when referring to the UniTask
type I see:
The type or namespace name 'UniTask<>' could not be found (are you missing a using directive or an assembly reference?) [Assembly-CSharp]
For reference UniTask is from here: https://github.com/Cysharp/UniTask
Environment information
VSCode version: 1.51.0 C# Extension: 1.23.5 Unity: 2019.4…14f1
Dotnet Information
.NET Core SDK (reflecting any global.json): Version: 3.1.201 Commit: b1768b4ae7Runtime Environment: OS Name: Windows OS Version: 10.0.19041 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.201\
Host (useful for support): Version: 3.1.3 Commit: 4a9f85e9f8
.NET Core SDKs installed: 2.1.801 [C:\Program Files\dotnet\sdk] 2.2.109 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] 3.1.201 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.3 [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 |
---|---|---|
auto-rename-tag | formulahendry | 0.1.5 |
code-settings-sync | Shan | 3.4.3 |
code-spell-checker | streetsidesoftware | 1.9.3 |
cpptools | ms-vscode | 1.1.0 |
csharp | ms-dotnettools | 1.23.5 |
flatbuffers | gaborv | 0.1.0 |
gitlab-workflow | GitLab | 3.6.0 |
html-tag-wrapper | hwencc | 0.2.3 |
npm-intellisense | christian-kohler | 1.3.1 |
python | ms-python | 2020.10.332292344 |
remote-ssh | ms-vscode-remote | 0.55.0 |
remote-ssh-edit | ms-vscode-remote | 0.55.0 |
remote-wsl | ms-vscode-remote | 0.51.2 |
rust | rust-lang | 0.7.8 |
rust-analyzer | matklad | 0.2.376 |
serverless-ide-vscode | ThreadHeap | 0.5.26 |
shopify-liquid | sissel | 2.3.0 |
Theme-MarkdownKit | ms-vscode | 0.1.4 |
vim | vscodevim | 1.17.1 |
vscode-eslint | dbaeumer | 2.1.13 |
vscode-npm-script | eg2 | 0.3.13 |
vscode-proto3 | zxh404 | 0.5.2 |
xml | DotJoshJohnson | 2.5.1 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
I had the exact same Problem with UniTask (last version)
1.2.4
1.63.0
1.23.17
2020.3.21f1
the idea is how to force VSCode to check again for Assembly references (as they are added and Unity sees them, i.e. no errors are shown on Unity’s side), solution was to
delete all
.sln
and.csproj
files from the root of the Unity project and restart the editor.and this did the trick 😉 .
it took me a sometime to figure that out, hope that helps, if anyone came later looking for a solution. 😄
@OsamaMSoliman Thanks for the help! Instead of deleting all the files, I found success reloading the
*.csproj
files from UnityUnity -> Edit -> Preferences -> External Tools
Generate .csproj files for:
and clickRegenerate Project Files
with everything unchecked.Ctrl + Shift + P
and runDeveloper: Reload Window
Now UniTask has intellisense 😄