Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Import new Package Manager UI and .unitypackage

Discussion in 'Package Manager' started by JPFerreiraVB, Jan 30, 2019.

  1. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    35
    Hi folks.

    So bear with me while i explain the problem. Keep in mind i'm a newbie when it comes to Packages, we all gotta learn new things. :)

    The context: I'm on a studio divided in two teams. One that creates the Core of the project (scripts/base models/base maps/etc). Another that imports that core, and extends the project (new images/ new maps/ new models/ etc).

    The problem: The core team wants a way to develop the core part of the project, and make available new versions for the project teams to update on their project and make use of.

    The current "solution" for creating a .unitypackage: What i was able to implement was: I create a git repository with the core project. A jenkins job that create and version the .unitypackage and export it to nexus repository.

    The current "solution to import the .unitypackage: Here i have two solutions: Well the first one is manually. Download from nexus and import it to the project.
    The second was a bit more advanced. I modify the manifest.json file of the project, and added the line:

    "com.company.package": "file:C:/_Packages/CorePackage"
    , that points to the downloaded .unitypackage.

    Now the problems i'm facing and need some guidance on.

    The .unitypackage: When modifying the manifest.json of the project, i'm able to import the .unitypackage, but, only "zipped", shouldn't it automatically extract the content? (I need to manualy, select import package -> costum package -> only here the package is extracted.

    How to properly use Package Manager: From what i could tell the ideia is that this line

    "com.company.package": "file:C:/_Packages/CorePackage"
    , points to a git repository where the package is.

    Question1: does the package needs to be uniziped? Can or Can not be in the .unitypackage format
    Question2: how should the manifest format be, in order to import a specific version of the package? And how should the repository look like to handle this pipeline.

    Hope you made it this far. If so, please help me :D

    Regards
     
  2. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    518
    the .unitypackage format is the legacy format used in the asset store (basically a zip that dumps its contents directly into assets)

    the new package manager works like a proper package system. given that you already have a nexus repository, you should do something like this:
    - publishing: publish your package directly into your nexus, as if it were a regular NPM package
    - importing: setup a scoped registry in your manifest, then reference your packages by version as if it were an official package

    the only thing missing is update notifications and discovery in the UI (but the UI is itself a package, you can "fork" it and add your registry integration manually for now)
     
    JPFerreiraVB likes this.
  3. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    35
    @M_R Thanks for the help.

    So after your help and some other folks, i was able to get things running using github.

    I didn't test yet on the companies GItLab, but i think it will not be a problem.

    Thank you so much for your help. I will create a post, with all the steps needed to create this pipeline.

    Best regards
     
  4. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    35
    @M_R guess i was wrong!

    The GitLab is not public. Any update / Workaround on authenticating to a private repository?
    Also on our nexus machine, we can not have a folder structure, like Unity Package Manager depends. Everything that goes inside nexus is zipped into a single file.

    Best regards
     
  5. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    518
    the package would be unzipped by upm/npm when you install it, provided it's in the correct format.

    for private registries, you could put a basic auth token directly in the manifest.
    for private git repos, if you setup ssh it should work. url should be like this
    ssh://git@host.org/company/repo.git#tag
     
  6. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    35
    Can you help me on that basic auth token? Is not that basic for me :)
    We are using GitLab, and i have to login on the LDPA option. (Dont know if it makes a diference)


    "registry":"https://git.intra.company.com",
    "always-auth":true,
    "email":"myusername",
    "_auth":"mypassword",
    "dependencies": {
    "com.company.awesomeplugin":"ssh://git@git.intra.company.com:pathtoplugin/awesompluginrepository.git"
    }



    If i try this it gives me error. "fatal: could not read from remote repository Make sure you have the correct access rights"
     
  7. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    518
    _auth should be a base64 encoding of
    username:password
    (with the colon) if I remember right. search "basic auth token". also email is the actual email (different from username)
     
  8. JPFerreiraVB

    JPFerreiraVB

    Joined:
    Sep 18, 2017
    Posts:
    35
    Thank you i got it reading from the private git repo.

    On another topic.

    What should the correct format be?
    Using this as dummy example:




    Does this manifest is correct?

    Code (JavaScript):
    1. {
    2.   "scopedRegistries": [
    3.     {
    4.       "name": "Main",
    5.       "url": "https://my.company.com/nexusregistry/GoogleChrome",
    6.       "scopes": [
    7.         "com.my-company", "com.my-company.chromePackages"
    8.       ]
    9.     }
    10.   ],
    11.   "dependencies": {
    12.     "com.my-company.package1": "71.0.3578.98"
    13.   }
    14. }
    Again, thank you so much for your help
     
  9. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    518
    should be, if the zip contents are in the correct format and
    package.json
    is setup correctly.
    if you pushed the package with
    npm publish
    then it should work