Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity with VS Code: .sln generated is missing assemblies. Only .sln generated by Studio works (with

Discussion in 'Editor & General Support' started by Tudvari, Sep 30, 2021.

  1. Tudvari

    Tudvari

    Joined:
    Jun 3, 2014
    Posts:
    30
    After every Unity update I have a lot of problem with missing assemblies in Visual Studio Code.

    The type or namespace name "UI" does not exist in the namespace "UnityEngine"

    But after some messing around, somehow it always becomes fixed. I updated Unity again and now after wasting hours I decided to do it the right way and find out the source of the problem.

    As it turns out the problem is simply that the .sln generated when the external editor is VS Code is just simply missing a lot of assemblies: (and its icon is VS10 instead of VS15)

    Here's the full difference: Link

    If I switch the external editor to VS Studio and click Regenerate Project Files, the .sln is now full of assemblies. (if I would just switch to it, it wouldn't touch the sln)

    So now I switch back to VS Code, voilá it works because the assemblies are in the .sln.

    BUT for some reason if I restart Unity the .sln is always regenarated because possibly it detects that it has been generated by VS Studio while the current editor is VS Code.

    So it's missing the assemblies every time I restart Unity.

    Now at least I know that every time I launch Unity,

    1. I have to switch to VS Studio,
    2. click Regenerate Project Files,
    3. and then switch to VS Code.
    But before the update it was fine. It's always like this and then somehow it becomes fixed automatically at startups as well.

    What's causing this, how could I fix it? Thanks in advance!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,713
    My only advice in this area is as follows, and sounds like you're already doing the first thing:

    This may help you with intellisense and possibly other Visual Studio integration problems:

    Sometimes the fix is as simple as doing Assets -> Open C# Project from Unity. Other times it requires more.

    https://forum.unity.com/threads/intellisense-not-working-with-visual-studio-fix.836599/

    Also, try update the VSCode package inside of Unity: Window -> Package Manager -> Search for Visual Studio Code Editor -> Press the Update button

    Also, this: https://forum.unity.com/threads/no-suggestions-in-vscode.955197/#post-6227874
     
  3. Tudvari

    Tudvari

    Joined:
    Jun 3, 2014
    Posts:
    30
    I already tried upgrading CS Code Editor but it's already up to date. Also tried downgrading during previous tries (not this time) and that didn't help.

    Clicking Open C# Project didn't help.

    I installed the latest mono-develop from the site in the thread, but still didn't help.
     
  4. Tudvari

    Tudvari

    Joined:
    Jun 3, 2014
    Posts:
    30
    I've uninstalled every VS product, my current Unity, and then restarted the computer.
    Then I installed the newest Editor (2021.1.26f1) with VS, etc, but the problem still persists.
     
  5. PortgateStudios

    PortgateStudios

    Joined:
    Aug 24, 2020
    Posts:
    2
    I desperately need a fix for this issue :\ On my other PC it works perfectly for some reason.