Search Unity

Exclude Packages from Build

Discussion in 'Package Manager' started by pdinklag, Nov 20, 2019.

  1. pdinklag

    pdinklag

    Joined:
    Jan 24, 2017
    Posts:
    51
    Cheers!
    I am doing the first experiments with builds of my project (2019.2) and of course, a build should be as small as possible. I noticed a few minor annoyances concerning packages that should be addressed in the future IMO.

    My first issue is that all "Built-in packages" are always included in the build, even when I explicitly disable some of them for my project. To name just one example, I disabled the XR package, yet the build contains UnityEngine.XRModule.dll. Why?
    Apparently, this has already been asked very recently, but a tool that will tell me what packages are included in the build won't help here - disabled packages (even the built-in ones) shouldn't end up in a build in the first place.

    Secondly, there are packages that I do use in my project, but really only for development. A good example is the Playable Graph Visualizer. It's a useful development tool, but there's absolutely zero reason for it to be included in a build. After all, it also does eat away some performance (not much of course, but it's only an example). Is there any way, or is one planned, to explicitly exclude certain packages from a build?
     
  2. samuelb_unity

    samuelb_unity

    Unity Technologies

    Joined:
    Nov 13, 2017
    Posts:
    72
    Hi @pdinklag,
    Are you sure that all built-in packages are included in the build? If so, this sounds like a bug. Disabling a
    com.unity.modules.
    package in the project should indeed exclude it from the build. In the Package Manager UI, under "Built-in packages" can you check for "XR" whether it says "Is being used by" anything?

    If code or assets from this package are not being used anywhere in the project then the build pipeline should be smart enough to exclude these assets from the build. I'm not super familiar with PlayableGraph Visualizer, do you have to attach this to a scene in any way?

    Currently this is not possible, we rely on the build pipeline to be smart about picking assets. I will share this feedback with the team though to see if it's something we can improve :)
     
  3. pdinklag

    pdinklag

    Joined:
    Jan 24, 2017
    Posts:
    51
    Hey and thanks for the reply!
    Just to get this out of the way first, I'm using Unity 2019.2.8 and the Package Manager UI is at version 2.2.0.

    Let's see. In the UI, I cannot find any text "Is being used by", but for no package actually. I do see dependencies, but that's the inverse direction. Is it a new feature maybe that's not in 2.2.0 of the UI?
    In the screenshot you see an excerpt of what I see for built-in packages, XR being selected:
    pm.jpg

    I also attached my manifest.json file to this post so you can have a look at that.

    You see how, for example, all packages below "Umbra" are disabled. Yet, the corresponding libraries show up in my build:
    Clipboard02.jpg
    It does seem to be the case for all built-in packages that I disabled.

    It's not attached to any scene. Basically it defines a singleton where you register a playable graph to be visualized. I do use it in a script, but I just double-checked that there's only one usage and it's within a #if UNITY_EDITOR block.

    However, I just saw the package has an assembly definition file set for "Any Platform", so I guess this isn't much of a problem in the package manager, but rather a question of why it's not marked as editor only.

    It'd certainly be a nice to have! :)
    Of course, in my case, we're talking a bunch of extra kilobytes in the build, but these are just examples.
     

    Attached Files:

  4. cassandraL

    cassandraL

    Unity Technologies

    Joined:
    Dec 7, 2017
    Posts:
    108
    Hello,
    When you disable a module that is used by another one, you should see a window appearing telling you about it.
    For example, to disable XR, you must first disable the VR module. Therefore, no need to read through the dependencies.

    As for the modules not being bundled in the final build, I think you should file a bug.

    Thank you
     
  5. pdinklag

    pdinklag

    Joined:
    Jan 24, 2017
    Posts:
    51
    Whoops yeah, that one I knew!

    Will do, thanks!

    EDIT: A bug report has been filed: https://issuetracker.unity3d.com/is...odules-are-included-when-building-the-project
     
    Last edited: Dec 3, 2019