Automated build problem 5.1.1p3 UnityEditor.dll referenced (manual build works fine)

Hi folks.

I have a problem since 5.1.1f1 with my automated build. The build fails due to:

ArgumentException: The Assembly UnityEditor is referenced by Assembly-CSharp ('Library/ScriptAssemblies/Assembly-CSharp.dll'). But the dll is not allowed to be included or could not be found.
11:39:29 at UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1 alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2 cache, BuildTarget target) [0x0020d] in /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:154
11:39:29 at UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch, BuildTarget target) [0x00015] in /Users/builduser/buildslave/unity/build/Editor/Mono/AssemblyHelper.cs:192
11:39:29 UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, BuildTarget, BuildOptions, Boolean, UInt32&)
11:39:29 UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, BuildTarget, BuildOptions, UInt32&) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/BuildPipelineBindings.gen.cs:200)
11:39:29 UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/editor/BuildPipelineBindings.gen.cs:147)
11:39:29 BuildHelper:GenericBuild(String[], String, String, BuildTarget, BuildOptions) (at Assets/Editor/BuildScript/BuildScript.cs:252)
11:39:29 BuildHelper:performUnityBuild() (at Assets/Editor/BuildScript/BuildScript.cs:181)

Strange thing is, that if I build manually everything is fine. I can append to the existing project, as well as replace it without the error. If I deleted the library folder (which will lead to a full reimport) it also runs fine (well, that’s mostly like replacing manually).
The command to start the build process is:

-quit -batchmode -nographics -buildTarget ios -projectPath ${WORKSPACE} -executeMethod BuildHelper.performUnityBuild

I tried to figure out where the reference in the code may be, but all occurances are inside a #if UNITY_EDITOR define which worked before quite nicely.

Does anyone has a tip how I can figure out where the reference may be? Is there anyone else having the same problem?

I did not fully understand the scenario from your description…

You are building your game from the command line - which is failing (with the error you posted).
When building from the editor it works just fine?

I didn’t follow the part about “appending or replacing” - do you mean the Xcode project ?

What i would do is try to trace the source of error. Unity runs a couple of extra “postprocessor” steps after a build, this may be one of them (I think that BuildPipeline.BuildPlayer InternalNoCheck is a native method, or calls into a native method, so the call into AssemblyHelper must occur some time later from native code).

You could try to launch MonoDevelop, under Run → Exceptions, add ArgumentException (you can even add all exceptions) to “Stop in exceptions”. This makes sure that on any exception - even an internal one, you would be paused and could inspect the current state of the program.

Next, kick off a build that should fail (from command line), and once Unity starts, attach to it in MonoDevelop (Run → Attach to process).

Let it run and then (hopefully) it will break on the exception. Then you could (maybe…) examine the exception object, see where it’s coming from, what class is referencing UnityEditor, etc.

Let me know if that helped in any way :slight_smile:

Hey liortal.

Yes, you’re right, it’s a xCode and Android build which is build. And yes, if I manually build the version it always runs without problems. Only if I let my Jenkins Buildserver do the job (which is triggering the build via command line) it throws the error.

Good point to attach the debugger for the buildprocess, I’ll try this one. Thanks!

1 Like

Update this thread if you have found the cause for this issue :slight_smile:

Sure.
Sadly I wasn’t able to fix the problem yet. At least for the xCode build I could fix the problem by commenting out every script in the project which references the editor (even in #if UNITY_EDITOR defines), build the app and revert every script. That worked strangly, but not for Android. I even tried to figure out which script was causing the problem, but it seemed not to be related to a specific script.