Search Unity

How to structure custom package to work with git dependency?

Discussion in 'Package Manager' started by ZammyIsOnFire1, Jul 17, 2019.

  1. ZammyIsOnFire1

    ZammyIsOnFire1

    Joined:
    Sep 29, 2014
    Posts:
    19
    Hello

    I am working on a custom package. I have followed xhttps://docs.unity3d.com/Manual/CustomPackages.html#EmbedMe and created an embedded package. I have structured it as xhttps://docs.unity3d.com/Manual/cus-layout.html with [ROOT] being the [ProjectROOT]/Packages/com.tabtale.debugmenu/.

    In another project I have referenced custom package git repo as described here: xhttps://docs.unity3d.com/Manual/upm-git.html.

    When PackageManger gets my custom package I get my package but also Assets and ProjectSettings folder from Unity project where my custom package is embedded. This leads to errors like this one:
    Read only asset Packages/com.tabtale.debugmenu/ProjectSettings has no meta file.


    I believe I have my setup wrong and that this is not an issue with PackageManager. Unfortunately I have not see an actual complete example of a custom package. That could help a lot people like me.

    I have attached log files.

    All tips and help highly appreciated.

    Thank you!

    ps. Links intentionally broken! Spam filter is denying me ability to post.
     

    Attached Files:

    • logs.zip
      File size:
      22 bytes
      Views:
      514
  2. ZammyIsOnFire1

    ZammyIsOnFire1

    Joined:
    Sep 29, 2014
    Posts:
    19
    Ok, when I moved my package to root of repository everything worked as expected.

    The problem that I have now is how do I actually develop my package? A Unity project that is not commited and imports the package locally maybe? How do you guys do it?
     
  3. samuelb_unity

    samuelb_unity

    Unity Technologies

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

    So if understand, your 2 projects are set up like this:

    Code (CSharp):
    1. Project A
    2.   - Packages
    3.     - manifest.json
    4.     - com.tabtale.debugmenu
    5.       - .git (package repo root)
    6.       - package.json
    7.  
    8. Project B
    9.   - Packages
    10.     - manifest.json with "dependencies" { "com.tabtable.debugmenu": "repo-url.git <or> file://path.git" }
    This looks like a good setup to me! So in terms of developing your package, you would open Project A and do your development in there, then commit and push the changes from the root of your package repo (using the git command line or an application like GitHub desktop). Then when opening Project B, you can consume the git package but not develop it.

    Note: in Project B, you can either use a git URL or use a local file://path to get the package. If using a URL, we will lock the package to a specific git commit when cloning the repo whereas if using a local file path, you will always get the latest package contents at that path. If using a URL, you can remove the "lock" entry from the project manifest to pull the latest package contents.

    Let me know if you have more questions :)
     
  4. ZammyIsOnFire1

    ZammyIsOnFire1

    Joined:
    Sep 29, 2014
    Posts:
    19
    Hello Samuel!

    Yeah that is my setup but it does not work. When I import my package in Project B I get the issues mentioned in first post. I stripped it down of the project and left only the package.

    Now I have imported it "locally" into Project A but my C# interpreter (visual studio code + Omnisharp) fails to work as the package is outside of project root.

    When I am importing my package in Project B why do I get all the files from Project A? (Like Asset folder and ProjectSettings). I get the package correctly but with extras. If this does not happen then I can work with embedded package in Project A.
     
  5. samuelb_unity

    samuelb_unity

    Unity Technologies

    Joined:
    Nov 13, 2017
    Posts:
    151
    It sounds to me like the git repo you are referencing from Project B is actually initialized at the root of Project A.
    i.e. you have:
    Code (CSharp):
    1. Project A
    2.   - .git (repo root)
    3.   - Assets
    4.   - ProjectSettings
    5.   - Packages
    so the git repo is tracking the whole project.

    It should be:
    Code (CSharp):
    1. Project A
    2.   - Assets
    3.   - ProjectSettings
    4.   - Packages
    5.      - my-package
    6.         - .git (repo root)
     
    brownboot67 likes this.
  6. ZammyIsOnFire1

    ZammyIsOnFire1

    Joined:
    Sep 29, 2014
    Posts:
    19
    Ohhh that makes complete sense! Thank you!
     
    samuelb_unity likes this.