Since updating Unity I am unable to compile the project code in Visual Studio. It still compiles and runs in the Unity Editor but Visual Studio gives hundreds of missing reference errors (*"The type or namespace name 'XXX' could not be found (are you missing a using directive or an assembly reference?)"*). This includes files which I wrote, i.e. my own created namespaces.
Nothing I've tried works (see below) except for one thing. If I manually remove the references to all four assemblies in visual studio and re-add them, the solution will compile. But when I then close VS and reopen the same error comes up.
The assemblies are Assembly-CSharp, Assembly-CSharp-Editor, Assembly-CSharp-Editor-firstpass and Assembly-CSharp-firstpass. The normal ones that get created as far as I know.
Why does the reference break each time I restart VS?
Versions:
Unity 2019.3.12f1 Personal.
Visual Studio Community 2017 15.9.22.
I've tried:
- all of these https://stackoverflow.com/questions/29962432/visual-studio-refuses-to-build-project-due-to-missing-assembly-reference-that-is
- all of these https://stackoverflow.com/questions/450999/are-you-missing-an-assembly-reference-compile-error-visual-studio
- Removing the .vs folder and all VS files from the Unity project folder and letting the editor regenerate them. Also regenerated manually from within unity
- Making sure Visual Studio (and the Visual Studio Tools for Unity (which is installed using the Visual Studio installer)) are fully up to date.
- Updated VS to the latest version
- Removed VS Code package (I'm not using Code) from Unity, then readded.
- A number of restarts of Unity and VS in between all the above.
↧