Finding the Problematic dll in "Extracting Referenced dlls Failed" (Unity5)

We are starting to update to Unity5. After upgrading from 4.5.2f1 to 5 we have started to have a problem making builds. Our scenes / projects work correctly in Play Mode. However when we build any scene (including no scene / blank scene) we get the following errors.

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Modules.DefaultPluginImporterExtension+c__AnonStorey63.<>m__E6 (UnityEditor.PluginImporter imp) (at C:/buildslave/unity/build/Editor/Mono/Modules/DefaultPluginImporterExtension.cs:133)
System.Linq.Enumerable+c__Iterator1D1[UnityEditor.PluginImporter].MoveNext () System.Collections.Generic.List1[UnityEditor.PluginImporter].AddEnumerable (IEnumerable1 enumerable) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:128) System.Collections.Generic.List1[UnityEditor.PluginImporter]…ctor (IEnumerable1 collection) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:65) System.Linq.Enumerable.ToArray[PluginImporter] (IEnumerable1 source)
UnityEditor.Modules.DefaultPluginImporterExtension.GetCompatiblePlugins (System.String buildTargetName) (at C:/buildslave/unity/build/Editor/Mono/Modules/DefaultPluginImporterExtension.cs:133)
UnityEditor.Modules.DefaultPluginImporterExtension.CheckFileCollisions (System.String buildTargetName) (at C:/buildslave/unity/build/Editor/Mono/Modules/DefaultPluginImporterExtension.cs:157)
UnityEditorInternal.PluginsHelper.CheckFileCollisions (BuildTarget buildTarget) (at C:/buildslave/unity/build/Editor/Mono/Plugins/PluginsHelper.cs:25)
UnityEditor.HostView:OnGUI()

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.PluginImporter+c__AnonStoreyD.<>m__E (UnityEditor.PluginImporter imp) (at C:/buildslave/unity/build/artifacts/generated/common/editor/PluginImporterBindings.gen.cs:104)
System.Linq.Enumerable+c__Iterator1D1[UnityEditor.PluginImporter].MoveNext () System.Collections.Generic.List1[UnityEditor.PluginImporter].AddEnumerable (IEnumerable1 enumerable) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:128) System.Collections.Generic.List1[UnityEditor.PluginImporter]…ctor (IEnumerable1 collection) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:65) System.Linq.Enumerable.ToArray[PluginImporter] (IEnumerable1 source)
UnityEditor.PluginImporter.GetImporters (System.String platformName) (at C:/buildslave/unity/build/artifacts/generated/common/editor/PluginImporterBindings.gen.cs:103)
UnityEditor.PluginImporter.GetImporters (BuildTarget platform) (at C:/buildslave/unity/build/artifacts/generated/common/editor/PluginImporterBindings.gen.cs:111)
UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List1 alreadyFoundAssemblies, System.String[ ] allAssemblyPaths, System.String[ ] foldersToSearch, System.Collections.Generic.Dictionary2 cache, BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:129)
UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[ ] paths, System.String[ ] foldersToSearch, BuildTarget target) (at C:/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:198)
UnityEditor.HostView:OnGUI()

Error building Player: Extracting referenced dlls failed.

I’ve been researching the problem and have seen a number of solutions:

  • Changing API Optimization to 2.0 instead of 2.0 subset
  • Restarting Unity and/or computer
  • Not entering play mode and simply building

Each of these solutions (and some others) have been tried and do not help.

I know from my research that the issue is an out of date or problematic dll or plugin somewhere in our assets. We confirmed this by removing all non-script assets and tried to build. This was successful.

My question is how can I learn which dll etc. is the problematic one? Most other posts of this kind have messages that state the exact dll that is the problem. The above is all the output I have. I have also tried looking in the Unity Editor Log and haven’t found anything more helpful in there either.

We have tried to build with both WEBGL and Standalone and this issue occurs in both.

Could you please create a bug with project attached? Also which Unity version is this?

NullReferenceException was thrown in plugin management code, in place where it should have been impossible, so repro case would be very welcomed.

You can also acquire the list of plugins yourself, by calling PluginImporter.GetAllImporters() from editor script, it seems one of the element was null, but like I said, it should have been impossible.

Thank you for your quick reply Tomas1856 and for the tips.

Fortunately after painstakingly moving the files to a different working branch a little at a time we discovered that the problem lay with the library directory of the original project. Once this was deleted and regenerated by Unity the problem was resolved. I believe that the library folder was not cleared before the update to Unity 5 and therefore something may have been corrupted. Regenerating the library folder succeeded in fixing the problem.

Hmph, Library folder shouldn’t have be the problem, but I am glad it works for you know, I’ll close the internal bug for now.

Cheers