Visual Studio 2017 keeps trying to find deleted scripts

Hi guys.

I’m having a problem with visual studio and it’s sort of annoying.
So whenever I make changes in my project within unity, and then switch to visual studio to edit scripts, none of the auto code things load properly.
All of the namespaces at the top and anything associated with unity fails to load properly.
What’s more is that when I delete a script within unity, and then switch back to visual studio, visual studio complains that the file is missing… uh duh! I deleted it?

It just seems that Visual Studio and Unity keep losing synchronization with each other and any changes to the project are not reflected or are ignored within Visual Studio.

Does anyone know of anything that can fix this glaring issue? I’m using Windows 10 with Visual Studio 2017 Enterprise along with the most recent release of Unity3D.

Thanks in advance.

The way you launch Visual Studio matters. I’ve found that launching Visual Studio from Unity, either by double-clicking a script or by using the context menu action, creates a more stable connection. One can only assume this is because doing so generates a small crack in the membrane separating our universe from the next, allowing a benevolent-if-insubstantial daemon to sneak through and maintain the linkage.

Anyway, I don’t really like the connection for anything. I write all the code in Visual Studio as though Unity doesn’t exist - everything I can possibly write that way, at least. I configure my projects to compile assemblies into the Assets folder. This allows me to build and test my code quickly and with no interference from Unity interoperability.

If (and only if) I actually need the connection, then I open up the weird Visual Studio solution generated by Unity. I do this by double-clicking my one-and-only script compiled by Unity (Dummy.cs: class Dummy {}). That lets me do things like compile binaries that generate meaningful stack traces and, on very rare occasions, hook up the debugger.

Generally speaking, though, keeping the code stuff entirely as a concern of Visual Studio and the game design/UI/release stuff entirely as a concern of Unity has served me pretty well.

Are you sure that the solution and “csproj” files can be written by Unity? Unity usually updates / rewrites them whenever something changes in the project. Try deleting the solution and csproj file and let Unity recreate them. So you have the Unity tools installed in your VisualStudio version? (VisualStudio–>Tools–>Get Tools and Features)

Okay. Some real good things here.

First off, Monodevelop is not an option. I hate it and it should be removed.

I got Unity tools for visual studio and I run visual studio from within unity.

@MaxGuernseyIII your idea of compiling scripts as an assembly sounds rather interesting.
Do you think that if I included all of the libraries that I need in visual studio separately and made a DLL, then I could use those scripts as a manged plugin?

Use Mono Develop :slight_smile: