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

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,

  • I have to switch to VS Studio,
  • click Regenerate Project Files,
  • 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!

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://discussions.unity.com/t/778503

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://discussions.unity.com/t/805330/7

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.

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.

I desperately need a fix for this issue :\ On my other PC it works perfectly for some reason.