Search Unity

Question How to install a package but *only on some machines*?

Discussion in 'Package Manager' started by mcclure111, Oct 31, 2023.

  1. mcclure111


    Dec 10, 2016
    I am developing a game with Unity. This game is targeting a console (for the question it doesn't matter which one). To support the console, I must add four packages. These packages are NDAed by the console maker, so they can only be downloaded as .tgz files from a password protected website. I'm supposed to download the .tgz files and then say "add package from tarball" in the Package Manager. And this works. But…

    Now that I have the four secret files added to the project (that is, to the manifest.json), the project refuses to build on any machine which does not have the four .tgz files at an expected path. It says "Failed to resolve packages: Tarball package [NAME] cannot be found at path".

    This is bad because (1) the .tgz files are not needed on all machines; they are only needed when the console platform is selected in "Build Settings". So copying the tgz files to my Macintosh, where I also need to build, would be pointless because the console platform cannot build on Macintosh. (2) those .tgz files legitimately *should not* be copied to some machines, because they are NDA'd. There are some members of the project who do not have console devkits and should not be given copies of the .tgz, because it might be an NDA violation. (Of course for the same reason I probably cannot check the NDA'd .tgzs into version control.)

    What is the correct way to handle this?



    I *could* create a separate git branch, with the only difference being the four packages are listed in manifest.json in this git branch only. But this would be infeasibly inconvenient, I would have to do near-daily merges to always maintain both branches with the same code.

    What I eventually did do (and fixed the problem), but is unsatisfying, was creating an embedded package. I do the following steps for each tgz file

    * In Packages/, `mkdir PACKAGE_BASENAME`
    * In Packages/, `tar zxvf PACKAGE_BASENAME.tgz -C PACKAGE_BASENAME`
    * `cd Packages/PACKAGE_BASENAME` and `mv package/* .`
    * Add `/Packages/PACKAGE_BASENAME*` to .gitignore

    This adds the tgz packages to the current machine *only*, and without leaving any traces in git that will infect other machines. But the problem is it is many steps, and will be difficult for any non-technical member of the project to execute. I am going to have to write a .bat file or something.


    The documentation describes a way to make a machine-specific package configuration file named `.upmconfig.toml`. However, this appears to apply to things like passwords. I need to customize the manifest on a per-machine or per-target-platform basis.

    Are there any better options?
  2. CodeSmile


    Apr 10, 2014
    One way to solve this would be to automate the builds. Most developers targeting consoles likely have a build system (CI) already set up for this purpose.

    On the build machine you'd run the build via command line and provide a static script method that would then first import the necessary tarball packages before starting the build. That way the tarballs don't need to be in source control, or generally added to the project.