Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Other registries than Unity's own already work, nice!

Discussion in 'Package Manager' started by marijnz, May 29, 2018.

  1. marijnz

    marijnz

    Joined:
    Sep 20, 2012
    Posts:
    67
    I wanted to say I was pleasantly surprised to see that it's possible to point to the npmjs registry. I made a simple package (one C# file with a MonoBehaviour) that points to another package. (https://www.npmjs.com/package/dombo-is-great and https://www.npmjs.com/package/dombo-is-great-two).

    The only thing that was "odd" is that Unity requires dependencies of packages to have a version with a tag, such as "1.0.0-release", and not "1.0.0", otherwise it throws errors on the version parsing. Besides that and a couple errors here and there, I really like how it works! It perfectly downloaded the packages, offered to update them, compiling dll's out of them, and nicely referencing from the solution. Sweet!

    I'm not sure if this was already intended, but I'm happy to see that it is already possible ;)
     
  2. okcompute_unity

    okcompute_unity

    Joined:
    Jan 16, 2017
    Posts:
    756
    Hi @marijnz ,

    Just to understand how you achieved this, can you share your project manifest?

    Unity Package Manager relies on the *npm* protocol under the hood but there are no guarantees this will work forever ;)

    Regards,

    Pascal
     
  3. marijnz

    marijnz

    Joined:
    Sep 20, 2012
    Posts:
    67
    Hey, sure. Out of interest, would there be good reasons to deviate from the npm protocol? I think this actually is a great thing. It, for example, allows companies to distribute packages internally close to how Unity does it. I used npmjs just to try the idea out, but could of course host my own registry, as could a company.

    manifest.json:

    {
    "registry": "https://registry.npmjs.org",
    "dependencies": {
    "dombo-is-great": "1.0.2-unity"
    }
    }
     
    Ash-Blue likes this.
  4. okcompute_unity

    okcompute_unity

    Joined:
    Jan 16, 2017
    Posts:
    756
    Ok. This works, indeed :). But you are effectively blocking yourself from using all of Unity official packages.

    What I'm saying is, at this point, I cannot promise that the *npm* protocol will always work. We are not promoting the possibilities you discovered for this reason. You should not build a full production infrastructure around your discovery. Things might change. Only if you are ready to take that risk, go ahead. Private registries support is schedule for 2019.1 at the moment (not the plural form :p)

    What I can promise you though is that the day we expose you the option to create your own private registry, the experience will be on par with what you would expect with an *npm* registry :)

    Regards,

    Pascal
     
  5. marijnz

    marijnz

    Joined:
    Sep 20, 2012
    Posts:
    67
    It's all out of interest :) At work (Wooga), we use NuGet for internal sharing of packages, having our own dashboards, and tools such as https://github.com/wooga/Paket.Unity3D. Thanks for the answers, I wasn't aware this would make it impossible to use Unity's packages. I all the time assumed it was possible to have more than one registry endpoint. Cheers.
     
  6. capyvara

    capyvara

    Joined:
    Mar 11, 2010
    Posts:
    80
    As a test, using our internal nexus repository manager I've made a group that mirrors unity's + a private npm and published some test packages there.

    At our manifest.json we point to this registry group and use basic auth, ex:

    Code (JavaScript):
    1.  
    2. {
    3.   "dependencies": {
    4.     "com.ourcompany.testpackage": "0.0.1",
    5.     "com.unity.entities": "0.0.12-preview.5",
    6.     "com.unity.package-manager-ui": "1.9.9"
    7.   },
    8.   "registry": "https://packages.ourcompany.com/unity-group",
    9.   "email": "readonlylogin@ourcompany.com",
    10.   "always-auth": true,
    11.   "_auth": "BASE64AuthInfo"
    12. }
    13.  
    So we can have dependencies between ours packages and unity ones, but they still need to be manually added to manifest.json, since the way Unity shows the all tab is by querying a specific metadata of a package (com.unity.package-manager-metadata I think).
     
    kbobnis and M_R like this.
  7. okcompute_unity

    okcompute_unity

    Joined:
    Jan 16, 2017
    Posts:
    756
    Hi @capyvara ,

    Nice configuration! As you said, the
    com.unity.package-manager-metadata
    package is used to populate the *All* tab in the Package Manager UI. This is a way to limit the *All* tab to packages that we believe the quality is good enough to expose to all users. We never anticipated configuration like yours in our implementation ;)

    As I stated in a previous comment, we plan to support *private npm registries* in the future. It should support you use case and we will make sure your packages are searchable in the UI.

    Regards,

    Pascal
     
    Deleted User likes this.
  8. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,157
    Will it be possible for nuget?
     
  9. okcompute_unity

    okcompute_unity

    Joined:
    Jan 16, 2017
    Posts:
    756
    Hi @Thaina ,

    This is something we may consider in the future. But there is no short term plan to support *NuGet* registries.

    Regards,

    Pascal
     
  10. kbobnis

    kbobnis

    Joined:
    Oct 23, 2015
    Posts:
    6
    Hi Capyava. We got the same solution to work in 2018.3, but not in 2017.4. We're getting

    Failed to resolve packages: Package [com.test.package@0.0.1] cannot be found. Please see the Editor.log file for more information.
    In the editor log we see
    Refresh: detecting if any assets need to be imported or removed ... Failed to resolve packages: Package [com.test.package@0.0.1] cannot be found.
    Our local set up is:
    • nexus repository manager

    UnityPackageManger->manifest.json
    Code (JavaScript):
    1. {
    2.  
    3.   "dependencies": {
    4.      "com.test.package": "0.0.1"
    5.   },
    6.   "registry": "http://localhost:8081/repository/npm-unity-group/"
    7. }
    com.test.package -> package.json
    Code (JavaScript):
    1. {
    2.     "name": "com.test.package",
    3.     "displayName": "Test package",
    4.     "version": "0.0.1",
    5.     "unity": "2017.4",
    6.     "description": "This is a test package",
    7.     "keywords": [
    8.         "test"
    9.     ],
    10.     "category": "Unity"
    11. }
    in terminal i can type and get:


    Code (JavaScript):
    1.  npm info com.test.package  --registry http://localhost:8081/repository/npm-unity-group
    2.  
    3. com.test.package@0.0.1 | Proprietary | deps: none | versions: 1
    4. This is a test package
    5.  
    6. dist
    7. .tarball: http://localhost:8081/repository/npm-unity-group/com.test.package/-/com.test.package-0.0.1.tgz
    8. .shasum: ac054072525fd79eb02b277f0c3c315219f55c43
    9. .integrity: sha512-gdv45vYcFGqbY8k28VBL6e2kVcnhIfTHYGunfpOzoSdCcd3FxixGewF1uPdGdWzcsB7J6hyoZax5rrwr8Acozg==
    10.  
    11. dist-tags:
    12. latest: 0.0.1
    13.  
    14. published an hour ago by undefined <undefined>


     
    Last edited: Nov 21, 2018
  11. okcompute_unity

    okcompute_unity

    Joined:
    Jan 16, 2017
    Posts:
    756
  12. kbobnis

    kbobnis

    Joined:
    Oct 23, 2015
    Posts:
    6
    Hi @okcompute_unity, thank you for your response.

    yes, i know about scoped registries, they work. in this example i have used "registry" because it's recognized by both 2017.4 and 2018.3

    do you have any ideas why 2017.4 can not find our local package? the same configuration works in 2018.3
     
  13. okcompute_unity

    okcompute_unity

    Joined:
    Jan 16, 2017
    Posts:
    756
    @Philon, can you try removing the extra */* at the end of the registry URL configuration? We had a bug at some point with trailing */* in registry URL. The fix may have not been backported to 2017.4 :(
     
  14. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,061
    I've successfully set up a Verdaccio npm proxy with 2018.2. One thing to note is that older Unity versions only supports port 80, using another port like 8081 will fail. I haven't tried with 2018.3 but it seems that issue has been resolved.
     
    kbobnis likes this.
  15. kbobnis

    kbobnis

    Joined:
    Oct 23, 2015
    Posts:
    6
    Unity 2017.4 would not fetch port 8081 (or any other). When we used port 80 it started working!

    Thank you @Adrian it was exactly this.
     
  16. okcompute_unity

    okcompute_unity

    Joined:
    Jan 16, 2017
    Posts:
    756