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

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) enter image description here

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!