Search Unity

Question Can't build DLL without referencing Unity.CoreModule directly

Discussion in 'Scripting' started by HugoZink, Jul 2, 2020.

  1. HugoZink

    HugoZink

    Joined:
    Mar 4, 2018
    Posts:
    13
    I'm building a collection of editor scripts for Unity on Unity 2018.4.20f1. I made a separate assembly definition file for these editor scripts, and I'm using Visual Studio 2019 to compile them into DLL's.

    When loading the built DLL in another project, I get this warning:
    However, this appears to not be true. When I remove this reference from my C# project, I get build errors about UnityEngine.CoreModule missing:
    So Unity wants me to remove these references, but if I remove them, the project no longer builds. Is this a bug? I already have a reference to UnityEngine in the build.

    Any ideas?
     
    ernest_unity295 likes this.
  2. shuudev

    shuudev

    Joined:
    Feb 24, 2016
    Posts:
    4
    I also face same problem, any ideas ?
     
  3. theobject

    theobject

    Joined:
    Oct 6, 2010
    Posts:
    7
    Also having this problem. It seems like just using references to UnityEngine.dll and UnityEngine.UI.dll are not enough when building the dll in Visual Studio. It refuses to build unless I add references to:
    • UnityEngine.CoreModule.dll
    • UnityEditor.CoreModule.dll
    • UnityEngine.IMGUIModule.dll
    • UnityEngine.TextRenderingModule.dll
    • UnityEngine.UIModule.dll
    After I add those references is builds fine. But if I use that dll in a new empty unity project, I get the following build error:

    ArgumentException: The Assembly UnityEditor.CoreModule is referenced by mydll ('Assets/mydata/mydll.dll'). But the dll is not allowed to be included or could not be found.
    UnityEditor.AssemblyHelper.AddReferencedAssembliesRecurse (System.String assemblyPath, System.Collections.Generic.List`1[T] alreadyFoundAssemblies, System.String[] allAssemblyPaths, System.String[] foldersToSearch, System.Collections.Generic.Dictionary`2[TKey,TValue] cache, UnityEditor.BuildTarget target) (at <d6a6a4b561b9431dbfe2c61f7bf0d405>:0)
    UnityEditor.AssemblyHelper.FindAssembliesReferencedBy (System.String[] paths, System.String[] foldersToSearch, UnityEditor.BuildTarget target) (at <d6a6a4b561b9431dbfe2c61f7bf0d405>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)​
     
  4. ernest_unity295

    ernest_unity295

    Joined:
    Jul 9, 2021
    Posts:
    1
    Also interested in this topic
     
  5. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
    I have the same issue. Gah! Did you find a solution for this!?
     
  6. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
    I just solved this by building a "non-editor" version of the DLL for the target unity project I wanted to build (basically stripped out the editor code when building the DLL in visual studio)