Search Unity

Ignoring missing assembly reference in an asmdef

Discussion in 'Scripting' started by QFSW, Jun 18, 2019.

  1. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    Hi,

    I'm adding optional TMP support to my plug-in using a preprocessor called QC_TMP. When this preprocessor is active it uses TMP, when it's low TMP is not referenced at all in the project

    In order to make TMP mode work, I have to add TMP as a reference in my asmdef

    The problem is once you use the package without TMP, it breaks because of the missing assembly, despite the fact that it's not needed

    How can I work around this issue?
    Thanks
     
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Idk how to accomplish this in Unity, but overall in .NET there are conditional references for that purpose. In your project file:

    Code (CSharp):
    1. <Reference Include="NameOfDll" Condition="$(DefineConstants.Contains('CONSTANT_NAME'))">
    2.   <HintPath>Path\To\Dll\NameOfDll.dll</HintPath>
    3. </Reference>
    Maybe you may write some plugin to alter project files after they're regenerated by unity or before build like Rider devs did.
     
  3. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
  4. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    Unfortunately this only works in recent versions doesn't it?
     
  5. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
  6. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    Shame, I ended up writing my own code to modify the asmdef as needed which is much less than ideal (plugin developer so can't just upgrade)