Custom package dependencies

Hi,

this topic has popped up in a few places, but I couldn’t find a central/definite answer, so I thought I’d open a thread. A common use-case of package managers is to manage custom packages. This should also include dependency handling - keeping track of and moving dependency packages manually is a major headache. This includes having custom packages as a dependency for other custom packages. The last info I can find is that there’s internal discussions on whether that should even be a thing.
Have I missed something or is there currently no way to do that with UPM? I still feel like this is such a common scenario that I must miss a straightforward way of doing it.
Dependencies don’t seem to be supported neither as local packages (‘file:…’) nor as git packages. Having all packages ‘embedded’ defeats the point: That would also require manual moving when dealing with multiple projects - or writing custom batch/symlink voodoo in addition to UPM. The only option I’m not sure about is scoped registries (hosted locally?) - could that work?

1 Like

Hi @christoph_r ,

Yes, the Package Manager definitely supports dependencies. This is one of the main core features of the system :slight_smile:

But, as you noticed, we don’t currently support local and git packages dependencies. This will change soon. Stay tuned. For now, if you want to get support for custom package dependencies, you need to host a private registry and configure scoped registries in your project manifest.

Regards,

Pascal

1 Like

Hi @okcompute_unity / Pascal,
thanks for the reply! Glad to hear that is being worked on - and I hope I didn’t sound too harsh in the first post. Do you have any rough ETA for that?

You did not sound harsh at all :slight_smile: As for the ETA, 2019.3 feature is locked and we are moving on to 2020.x development. So this will (hopefully) be available in 2020.x release cycle.

Regards,

Pascal

1 Like

Because 2020.x is still a while to go, I decided to go for locally hosted scoped registries with verdaccio. Which seems to work… okay-ish (except that packages will need to be re-'publish’ed whenever they’re changed.)

One issue I’ve run into is that I’m not sure how pre-compiled dependencies are supposed to work. If I add them as dependencies into the project, it works fine. But if they’re dependencies of dependencies of a local package, it seems to break down / I can’t use the code.
To give an example, let’s consider these three exemplary packages:

  • BusinessLogic (depends on package Serialization, dependency specified in package.json)

  • Serialization (depends on package Protobuf, dependency specified in package.json)

  • Protobuf (precompiled, only consists of a package.json and a .dll + meta files)

Serialization cannot reference Protobuf if I only add BusinessLogic as a project dependency => throwing compiler errors. However, if I add Protobuf as a project dependency as well, it works.
It seems like something about the auto referencing of assemblies is off here - but I have no idea. How can I check that? And is there a way to tell which packages have been loaded (implicitly) as dependencies of dependencies?

Here’s another question: Is there a way to get the package manager to re-fetch a package again from the ‘remote’ server? Particularly if it’s a package dependency, not a project dependency.

  • close Unity

  • delete the caches:

  • /Library/PackageCache//

  • [in OSX] ~/Library/Unity/cache/packages/// (windows has its own path)

  • reopen Unity

1 Like

Thanks! The important part was to actually delete the packaged/tarball versions of the file as well as the unpackaged version. And the library.

However, we changed our approach (and ditched verdaccio) thanks to this very recently released Git dependency resolver. I extended it last night to also work with local packages/directory junctions. If someone is interested, I’ll look into doing a pull request.

Unfortunately, UPM is a filthy liar. It claims that Failed to resolve packages: [E:\GameDev\Core\Projects\UiPipelineSample\Packages] directory does not exist. No packages loaded. Which of course isn’t true. There are, however, embedded packages in that folder (via directory junctions).
Perhaps that has upset it? Even though I have the feeling it might be doing it out of spite and jealousy because I’m circumventing it in my attempts to get local package dependencies to work. If so, it is quite successful in destroying my plans and ruining my evening :<
Either way, I would be extremely grateful for pointers here. ( @okcompute_unity ? Or someone else from the team? Pretty please?)

Okay, the issue seems to be that there are directory junctions in the Packages folder which seem to be corrupted and cannot be deleted. That seems to be tripping the package manager up, though the error message of ‘packages directory does not exist’ is not exactly on point if that’s the case. Not sure if that’s a known issue?

Any update on this? Has this been included as a feature for 2020.x?

Git and local package dependencies are features that have been available in Unity for a while now. Local package dependencies were implemented in 2018.x. And Git package dependencies in 2019.x. For more details, you can read the Creating custom Packages section of the Unity user manual: Unity - Manual: Creating custom packages