Disable Packages for Specific Build Targets

What is the proper (or “most recommended”) way to disable Packages for specific build targets?

The best example I have is disabling Google Play Services-dependent packages (looking at you, Firebase!) when building for UDP or Amazon AppStore

Currently, for Firebase Remote Config, we rename the DLL and its meta, adding a “.disabled” extension to them. Yes, we rename the files in the PackageCache directory… :frowning:

Just being able to disable a few package files (without changing the manifest) would be very nice.

Hi @xLeo ,

Unfortunately there is no clear, recommended way to do this at this time.

If you’re looking into selectively disabling managed DLLs, I think you could perhaps use a fairly obscure class: UnityEditor.PackageManager.BuildUtilities (more specifically its method BuildUtilities.RegisterShouldIncludeInBuildCallback). I’m not certain this can help you, but it may be worth a try.

Tons of caveats:

  • doesn’t work with native plugins (.so, .framework, native .dll…)
  • doesn’t work with scripts
  • doesn’t work with non-code assets
  • basically, doesn’t work with anything but managed DLLs in packages

This API is obscure, hard to use, confusingly documented. It was intended for a very specific purpose and will probably be removed in the future, but I would expect that this won’t be before it goes through a proper deprecation flow (Obsolete warning), and is replaced with a better set of APIs to cover use cases such as yours.

In any case, thanks for bringing this up!

1 Like

Thanks for the feedback @maximeb_unity

Guess I’ll stick to renaming some files for now… :smile:

Probably I’ll work on toggling the packages on the package manifest file then… At least it should work well for UCB builds.

1 Like