Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to to remove "Mono dependencies included in the build"

Discussion in 'Web' started by arisdev82, Mar 28, 2019.

  1. arisdev82

    arisdev82

    Joined:
    Feb 27, 2019
    Posts:
    39
    Hello boys.

    I have removed all the unnecesary packages from the Package Manager (Text Mesh Pro, Vehicles, Physics 2D, etc) but Mono dependencies included in the build are almost the same:


    I understand some librarys are needed but all of them? Trying to remove them from Visual Studio solution didn't work, every time all references are regenerated. I tried to "remove" them from their paths, just to see what happens but it is not a good way, isn't it?

    So, my question is easy, can i remove "System.Net.Http.dll"? Just to know how to achieve it. Besides, is there any way to know what dependencies are reallly a need.



    Thanks!
     
  2. ihgyug

    ihgyug

    Joined:
    Aug 5, 2017
    Posts:
    194
    Maybe, try to edit the manifest.json of the project, it contains a list of dependencies and it probably won't regenerate them once you removed from there. Good luck :3
     
  3. achimeno

    achimeno

    Joined:
    Nov 13, 2014
    Posts:
    16
  4. doctorpangloss

    doctorpangloss

    Joined:
    Feb 20, 2013
    Posts:
    270
    Build Report Tool's analysis here is unfortunately inaccurate when I last tried. It's not entirely clear to me why.
     
  5. in3orn

    in3orn

    Joined:
    Jul 27, 2016
    Posts:
    1
    1. You can start with the code stripping:
    https://docs.unity3d.com/Manual/ManagedCodeStripping.html

    2. Next thing that could help is to create your own asmdef file for the project. Then you can tick Override references and control em manually in Assembly references section:
    https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html

    3. Since Unity 2019 there's also Define constraints section which works pretty well. Unfortunately it applies to specific package/plugin, so it's more author's responsibility. I think it's still worth asking plugin's creator whether he can think about such defines.

    3b. If not...
    In case of plugins you can simply override it and remember about it with every update. I know it's bad, however some custom script could validate it on release.

    I tried to play with Unity 2020 Version defines, but without success. Would be nice if it could have some expression for excluding specific module entirely.

    In case of packages you can do the same if you break the process and store the package locally...

    4. If you have packages that you use Dev/Editor only, you can think about having two different manifests for dev and prod. There are cases where you have no other option. For example if a package has the preserve attribute in it.

    The last thing:
    For me it would be nice to have something similar to Version defines but working recursively. For example we use UniTask but don't need UniTask.TextMeshPro as we're still using standard/legacy Text. The UniTask.TextMeshPro submodule has Version define entry for UNITASK_TEXTMESHPRO_SUPPORT with empty Expression. I assume it was intended to exclude the module from the build, but it doesn't. Probably because it means "take the lib with no version constraint". The code stripping doesn't help too.