Search Unity

Feedback Add an option to auto update packages.

Discussion in 'Package Manager' started by Circadence_DanW, Aug 19, 2019.

  1. Circadence_DanW

    Circadence_DanW

    Joined:
    May 23, 2018
    Posts:
    4
    A simple checkbox or something with each package to set it to automatically update whenever it discovers a newer version.
     
  2. okcompute_unity

    okcompute_unity

    Unity Technologies

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

    We have something in our plan to fulfill your use case. The UX might not be the same you propose though.

    This feature is available withouta proper UI in 2019.3 beta release. You'll need to manually update the project manifest to change the Package Manager resolution strategy.

    First, you need enable the lock file. The lock file is, for the moment, an opt-in feature. To enable the lock file, add the enableLockFile property with the value to your project manifest.

    Code (csharp):
    1.  
    2. {
    3.   "dependencies": {},
    4.   "enableLockFile": true
    5. }
    6.  
    Once this is done, a new packages-lock.json will get created alongside manifest.json as soon as you give focus back to Unity.

    Ideally, this file should:
    • Be source controlled: this is in order to ensure reproducibility over time and across machines;
    • Not be modified manually: because this file is generated by the Package Manager, it could be rewritten according to its internal rules and your changes, discarded. In the worst case, a bad manual edit could lead the file to be completely rewritten, for instance if there is a JSON syntax error. (In that case, VCS is your friend: see the above point.)
    The new lock file supersedes the lock property of the project manifest, which was used to track Git dependencies. If you intend to keep the lock file feature enabled, you can manually remove the lock property from the project manifest.

    Next, you need to change the resolution strategy.

    The resolutionStrategy configuration allows UPM to upgrade transitive dependencies based on well-known Semantic Versioning rules. The following values are supported:
    • highestPatch - In this mode, the SemVer expression "~" is applied to the requested version (e.g: ~1.0.0).
    • highestMinor - In this mode, the SemVer expression "^" is applied to the requested version (e.g: ^1.0.0).
    • highest - In this mode, the SemVer expression ">=" is applied to the requested version (e.g: >=1.0.0).
    Note that these SemVer expressions will never allow a dependency to jump from a stable to a pre-release (AKA preview) version of a package.

    In you case, you would set:

    Code (csharp):
    1.  
    2. {
    3.   "dependencies": {},
    4.   "enableLockFile": true,
    5.   "resolutionStrategy": "highest"
    6. }
    7.  
    Once a package has been resolved, it will remained locked at that version as long as it satisfies the SemVer expression of the strategy.

    The lock file needs to be deleted in order to force a refresh of transitive dependency versions. Any modification to the project manifest or to a writable package (ie: local or embedded) can potentially result in a locked version to be recalculated. As I said, at some point we will have something in the UI to remove the lock.

    Let us know if this would fulfill your requirement (albeit the missing UI).

    Regards,

    Pascal
     
  3. Circadence_DanW

    Circadence_DanW

    Joined:
    May 23, 2018
    Posts:
    4
    Thanks for the reply, this looks like it would do just what I want. :)
     
    okcompute_unity likes this.
  4. mschweitzer-sd

    mschweitzer-sd

    Joined:
    Aug 20, 2018
    Posts:
    1
    My coworker just alerted me to this thread, and this second bullet point seems pretty troubling and is pretty destructive to workflows we have setup on our side. We're relying on modifying the lock file manually in order to move git commit hashes manually.

    Is there an alternative method for specifying commit hashes? I don't see one in the Package Manager UI.
     
  5. UnityMaru

    UnityMaru

    Community Engagement Manager PSM

    Joined:
    Mar 16, 2016
    Posts:
    1,227
  6. Martin_Gonzalez

    Martin_Gonzalez

    Joined:
    Mar 25, 2012
    Posts:
    361
    @UnityMaru @okcompute_unity

    Unity is adding me packages and this breaks my CI environment. Is there a way to tell Unity not to add or update any dependency?
    I've the package-lock.json in the source control but Unity still add com.unity.ads package

    This is the log, and I don't have com.unity.ads in the package-lock file

    (Unity 2019.4.16f1)
    The following packages were added:
    com.unity.ads@3.5.2
    The following packages were updated:
    com.unity.test-framework from version 1.1.18 to 1.1.19
    com.unity.xr.legacyinputhelpers from version 2.1.4 to 2.1.6
     
    Petr777 likes this.
  7. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    It looks like the project you are opening in your CI run is older than the Unity version opening the project. This triggers the project update flow which updates packages to their minimum requirement and adds some default packages. A solution would be to update the project, prior to opening in the CI, to the same Unity version used in the CI.

    Hope this helps,

    Pascal
     
    Petr777 likes this.
  8. Martin_Gonzalez

    Martin_Gonzalez

    Joined:
    Mar 25, 2012
    Posts:
    361
    The problem was that I didn't have the ProjectVersion.txt commited :facepalm:
     
  9. fschmeidl

    fschmeidl

    Joined:
    Aug 2, 2022
    Posts:
    3

    Hello Pascal, thank you for this detail step-through. This might serve us well. 3 years later, I am wondering if the mentioned UI features is still in the planning?
     
  10. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    756
    HI @fschmeidl, I'm sorry, it turns out we haven't received a lot of requests to expose this feature in the UI in the end. If this feature is important to you, you can make your voice heard by clicking the *Submit a new idea!* tile in the Package Management product roadmap page.

    Regards,

    Pascal