Script changes don't compile

Deleting the ScriptAssemblies seems to work for me as well.

I’m having the same problem, thanks unidad2pete for redirecting me here (I posted on the answer forum: http://answers.unity3d.com/questions/1389229/visual-studio-script-changes-are-not-understood-by.html?childToView=1393372#comment-1393372).

I also had made a post about this in 2016: Saving project in VS does not always update Unity - Questions & Answers - Unity Discussions So this problem is not new for me.

Maybe it’s occuring more often recently, anyway it’s gotten to a point where it’s unbearable.
It’s impossible to work quickly with this. I uninstalled VS2015 and switched to VS2017 the problem is still there.

It’s hard to test the problem because it’s almost random. And typing Debug.Log(“1”) to Debug.Log(“20”) in the Start() method of a new project until it starts not updating anymore is starting to get on my nerves.

I do not have the same problem with MonoDevelop, it’s a Visual Studio - Unity issue.

Hi

Could you check if “Auto-Refresh” is enabled in “Unity Preferences” / “General” ? I’ve seen a few reports of this setting somehow being disabled automatically.

12 Likes

“Auto-refresh” was/is enabled in my case.

It’s enabled for me too

The next step in figuring out what is going is to look at what is written to the Editor.log.

What should be written when modifying a script something like this:

Updating Assets/Test.cs - GUID: 97a251c610b234069884001b95e27fb6…
----- Compute hash for Assets/Test.cs.
done. [Time: 95.932714 ms]
Refreshing native plugins compatible for Editor in 2.08 ms, found 4 plugins.
Preloading 2 native plugins for Editor in 1.61 ms.

----- Total AssetImport time: 0.261855s, AssetImport time: 0.214491s, Asset hashing: 0.000143s [0.5 KB, 3.481681 mb/s]

  • Starting compile Library/ScriptAssemblies/Assembly-CSharp.dll
  • Finished compile Library/ScriptAssemblies/Assembly-CSharp.dll

The above log statements show that a change to a script file has been detected and that the script is being recompiled.

If you could share what is written to your Editor.log on script change, then we could possibly get closer to figuring out what is causing this issue.

I will try to capture the moment in Editor.log when the script is not refreshed. In the meantime I found this.
I am using Visual Studio 2017 Community and it is located here: c:/program files (x86)/microsoft visual studio/2017/community/common7/ide/devenv.exe

EditorHelper: Attempting to use Visual Studio.
EditorHelper: Looking for a running Visual Studio session.
EditorHelper: Checking for Visual Studio installations.
EditorHelper: Searching for Visual Studio 2008 installation using the VS90COMNTOOLS environment variable.
EditorHelper: No Visual Studio 2008 installation found, trying with the registry.
EditorHelper: No Visual Studio 2008 installation found at all
EditorHelper: Searching for Visual Studio 2010 installation using the VS100COMNTOOLS environment variable.
EditorHelper: No Visual Studio 2010 installation found, trying with the registry.
EditorHelper: No Visual Studio 2010 installation found at all
EditorHelper: Searching for Visual Studio 2012 installation using the VS110COMNTOOLS environment variable.
EditorHelper: No Visual Studio 2012 installation found, trying with the registry.
EditorHelper: No Visual Studio 2012 installation found at all
EditorHelper: Searching for Visual Studio 2013 installation using the VS120COMNTOOLS environment variable.
EditorHelper: No Visual Studio 2013 installation found, trying with the registry.
EditorHelper: No Visual Studio 2013 installation found at all
EditorHelper: Searching for Visual Studio 2015 installation using the VS140COMNTOOLS environment variable.
EditorHelper: Found a Visual Studio 2015 installation here: c:/program files (x86)/microsoft visual studio 14.0/common7/
EditorHelper: Searching for Visual Studio 15 installation using the VS150COMNTOOLS environment variable.
EditorHelper: No Visual Studio 15 installation found, trying with the registry.
EditorHelper: No Visual Studio 15 installation found at all
EditorHelper: Your preferences indicate Visual Studio should be found here: c:/program files (x86)/microsoft visual studio/2017/community/common7/ide/devenv.exe
EditorHelper: We did not find a matching Visual Studio installation. We will look for a default Visual Studio installation.
EditorHelper: We found for a running Visual Studio session with the solution open.
EditorHelper: We’re not sure which version of Visual Studio was requested in the user preferences. We will use this running session.
EditorHelper: Using the existing Visual Studio session.
EditorHelper: Getting operations API from the Visual Studio session.

Same here after upgrade to 2017.1.0f3. My solution is manually Reimport the script files changed. Hope this bug can be fixed very soon.

Still getting the issue. I think it might be based on the computer? It happens on every project I create.

One workaround I found if it helps: I set Sublime Text (or another editor I guess) as default. Open it first (and don’t close) and then open Visual Studio to continue editing. It works perfectly for me.

PS: Well actually It doesn’t work at all :frowning:

It happens to us since we updated to Unity 2017.1 and VS 2017 on Windows 7.

EVERYONE is experiencing this issue at work.

At some point, Unity stop updating scripts for no reasons and we need to delete the “Library” folder to fix it, but the problem comes back randomly.

We have one bug report on this issue where the user investigated further. He is saying he is only experiencing this issue on Windows 7 when ReSharper is installed and the issue went away when he uninstalled ReSharper and he does not experience the issue on Windows 10 with ReSharper installed. He is using ReSharper Ultimate 2017.1.3.

One thing worth checking besides the Editor.log as I described above, is to check whether the Temp/ folder in the project contains assemblies when the updating of scrips fails. We compile the scripts to that folder first and them copy them to Library/ScriptAssemblies. It might be this copying from the Temp/ to Library/ScriptAssemblies that fails.

I’m using ReShaper 2017.1.3 too, it didn’t resolve this issue.
Yes, you’re right, the files in Library/ScriptAssemblies didn’t update automatically lead this issue, but don’t know how to fix it except reimporting scripts to force Unity recompiling again.

When a script fails to update, I get both Assembly-CSharp.dll and Assembly-CSharp.dll.mdb in my /Temp/ folder. When the issue stops and I get a successful update both files are removed.

I am not using ReShaper or any other extension that was not included in the default installation of Visual Studio from the Unity Installer.

Edit: This is happening consistently so far, so I can at least monitor if a script update failed by having the /Temp/ folder open on my second monitor. I also can consistently get an update to succeed if I close Visual Studio before reimporting the affected script(s), while reimporting with Visual Studio open usually fails.

It’s not related to ReSharper for me either, I tried both VS2015 and VS2017 vanilla versions and with ReSharper, it’s all the same.

Based upon the responses here I’ve attempted a blind fix for this issue.

You can try the fix by downloading a modified UnityEditor.dll for Unity 2017.1.0f3 from here:

http://files.unity3d.com/lukasz/share/UnityEditorDLL-2017.1.0f3-ScriptCompileChange.zip

How to use it:

  • Shut down any running instance of Unity 2017.1.0f3
  • In your Unity 2017.1.0f3 install folder there is a Managed folder with UnityEditor.dll and UnityEditor.dll.mdb
  • Make a backup copy of UnityEditor.dll and UnityEditor.dll.mdb from the Managed folder.
  • Copy the UnityEditor.dll and UnityEditor.dll.mdb from the zip file above into the Managed folder, replacing the original files.
  • Test script compile in Unity 2017.1.0f3 to see if this blind fix changes anything.

How to revert back:

  • Copy your backups of UnityEditor.dll and UnityEditor.dll.mdb back into the Managed folder of your Unity 2017.1.0f3 install.
5 Likes

Lukasz, i tried your dll files and it updated 20 changes in a row, that never happened before since 2017.1. I will keep using it and report back if it breaks again but for now it seems to be fixed.

1 Like

We have been using the fix @lukaszunity provided and haven’t had problems since. I’ll update this later today if we have the issue again later, but it looks like this fix did the trick.

Will this patch also work with 2017.1.0p4?

No. These .dlls are only work with Unity 2017.1.0f3