Search Unity

Use sub folder of repository as a package

Discussion in 'Package Manager' started by QFSW, Jun 10, 2019.

  1. QFSW

    QFSW

    Joined:
    Mar 24, 2015
    Posts:
    2,906
    Is there any way to make a sub folder of a repository the only files included via the package? Either by editing or moving the json

    Thanks
     
    Sonic1584 likes this.
  2. felipemunoz_unity

    felipemunoz_unity

    Unity Technologies

    Joined:
    Apr 5, 2019
    Posts:
    15
    Hello!
    As far as I am aware, this functionality is not directly supported by Package Manager yet (it will be in the future but i don't have a clear timeline). While you can add packages to your project using a git url, it would expect you to have the package structure directly in the root of that repository.

    One workaround I can think about though... If you have the following repository structure:
    . (Repository Root)
    |-- Package A
    |-- package.json
    |-- Package B
    |-- package.json

    Then what you could do is to have your repository cloned in the disk and reference those packages through file:/ references in your project manifest.json, as in:
    {
    dependencies: {
    "Package A": "file:<absolute or relative path to repository>/Package A"
    }
    }

    The above should allow you to just import Package A from your repository on that project, but you would still need to manually pull for updates.
     
  3. QFSW

    QFSW

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

    No problem, not a big deal

    Is it possible to whitelist/backlist files/folders to be included in the package either? This could also work?

    Thanks
     
  4. felipemunoz_unity

    felipemunoz_unity

    Unity Technologies

    Joined:
    Apr 5, 2019
    Posts:
    15
    The only method I know of that could suite your needs is adding a `~` to a folder you want to "ignore".

    So, let's assume you have
    . (Package A)
    |-- FolderWithCode
    |-- FolderWithOtherThings
    |-- FolderToIgnore

    By adding a ~ to FolderToIgnore you will be hiding everything in it from the asset database. So the final structure would be:

    . (Package A)
    |-- FolderWithCode
    |-- FolderWithOtherThings
    |-- FolderToIgnore~
     
  5. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Any update on this?
    Most of the users will need this.
    For example, I have a package I publish on the asset store, which is contained into a Unity project and hosted on github.
    Now I'd like to use it as a UPM across my own projects (and probably it'll be needed when the Asset Store will also transition to this format), and the most comfortable way of doing it is to add the package.json inside the Assets folder.
    Now the obvious need is to keep the same github repo also for the UPM package instead of creating a nested git repo locally, so instead of specifying giturl.com/repo, we could specify something like giturl.com/repo#/Assets
    Where #/ will represent the beginning of the path to checkout in the repo.
    Git already supports this: Link, Link2
     
    JoysonAtMercedesBenz likes this.
  6. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756