Search Unity

Use Repo Subfolder for Package Contents?

Discussion in 'Package Manager' started by kromenak, Nov 18, 2019.

  1. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    270
    Hello! Our team has actually been (mis)using NPM for the last year or two as a package management solution for Unity. We use NPM packages with git repo links to various custom packages, which works pretty well. However, I'm now looking into whether we should switch to use the Unity system!

    A common occurrence for us was that we don't want EVERY folder or sub-folder in our git repo to be part of the package used by a project. I think a great example is where the package makes use of native code projects to build plugins: you want to include the plugins in the end-user package, but not the C++ source code.

    A pretty good Unity-based example of this might be the experimental networking package: https://github.com/Unity-Technologies/multiplayer. Note that the actual package is not the root of the git repo, but actually the subfolder "com.unity.transport". At the root of the repo, there's also the folder "network.bindings" that contains all the platform-specific native code.

    In NPM, we could specify this in the package JSON like so:
    "files": [ "PackageFolder" ]

    This would cause ONLY the "PackageFolder" subfolder to be installed to the end-user's packages directory.

    Is there any way to get this type of behavior with UPM? I tried a test with one of our packages that uses native code, but UPM added the compiled so/a/dll/dylib files AND the native C++ source code and Xcode/VS project files to the target project.
     
  2. samuelb_unity

    samuelb_unity

    Unity Technologies

    Joined:
    Nov 13, 2017
    Posts:
    151
    Hi @kromenak,

    Glad to hear you are thinking of switching to Unity's Package Manager, hopefully it will fit your needs! Regarding the "files" attribute in package.json, you could switch to using .npmignore file(s) that would exclude files from the final package when it comes to publishing. As for adding packages via Git repo URLs, we are currently working on supporting Git repos where the package does not live at the root of the repo.