Search code examples
c#unity-game-enginevisual-studio-codecsprojomnisharp

Unity: Omnisharp is not finding referenced projects in VSCode


I recently upgraded to Unity 2019.3.0f6. When I opened one of my c# files, I noticed that UnityEngine.UI wasn't being recognized as a valid namespace. This caused me to get red squiggles whenever I referenced this namespace. IntelliSense also stopped working. This problem only shows up in VSCode, my project still runs just fine in Unity.

I checked the Omnisharp logs and found some errors that tell me Omnisharp is unable to find the UI .csproj file and a couple others.

[warn]: OmniSharp.MSBuild.ProjectLoader
    The referenced project 'UnityEngine.UI.csproj' does not exist.

What would cause this?

Things I've already tried:

  • Checking that the dotnet command works
  • Re-installing the c# vscode plugin
  • Deleting the .sln and .csproj files and letting Unity regenerate them
  • Re-installing Unity

Solution

  • It is a bug in version 1.1.4 of Visual Studio Code Editor package.

    These are the steps that I did to fix this issue:

    1. Open Window > Package Manager in Unity Editor
    2. Select Visual Studio Code Editor and click Remove
    3. Select "See all versions" under Visual Studio Code Editor
    4. Select version 1.1.3 and click Install
    5. Restart VS Code

    There is a forum discussion on this here

    And the actual issue is being worked on Unity Issue Tracker ticket here

    UPDATE:

    The current Visual Studio Code Editor package version 1.2.1 does not have this bug.