The Assembly Y is referenced by X. But the dll is not allowed to be included or could not be found

My Unity project references a dll “X” that has a reference to the assembly “Y”.
Since I developed X, I know what Y is used for, and I don’t need it for my Unity project. Therefore I don’t want to include “Y” in my Unity project.
Instead of making a second version of “X” that doesn’t use “Y”, I would like Unity to ignore the following error…

ArgumentException: The Assembly Y is referenced by X. But the dll is not allowed to be included or could not be found.
UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List1[T] alreadyFoundAssemblies, System.String[ ] allAssemblyPaths, System.String[ ] foldersToSearch, System.Collections.Generic.Dictionary2[TKey,TValue] cache, UnityEditor.BuildTarget target)
(…)

…and, of course, fail in runtime if Y is actually used.

Is that possible?

Thank you.

Not without making a “second version”. :wink:

I’m sure there is, somewhere within the IDE, to specify whether an assembly should be referenced or not for a specific build target. That way you would only have to switch build targets, and #ifdef some lines probably, to build and support both versions. Maybe a script that copies the two dlls to the locations you need them to be updated in. So you could just always build both if that’s fast enough for you.

Generally, the solution is to split “X” into “X1” and “X2”, where “X1” is what you put into your Unity project and “X2” that contains the functionality that requires the use of “Y”.

Unity cannot ignore this error, as it would fail during subsequent build steps (instead of failing at runtime).