Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug How can i resolve packages with api?

Discussion in 'Package Manager' started by Seraphim-Whiteless, Mar 3, 2021.

  1. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    Hi guys!

    How can i resolve packages with packagemanager api?

    resolve function is internal in Client.

    internal static void Resolve() => NativeClient.Resolve();



    PS
    in last version of package manager resolver does not start after packagemanifest modification.
     
  2. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    only reflection?

    MethodInfo method = typeof(Client).GetMethod("Resolve", BindingFlags.Static|BindingFlags.NonPublic|BindingFlags.DeclaredOnly);
    if (method != null)
    method.Invoke(null, null);
     
  3. Davidtr_Unity

    Davidtr_Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    34
    Hi,

    You need to enable the Auto Refresh preference or press Ctrl+R for the resolver to refresh your packages after editing the manifest manually.

    I hope this was helpful.
     
  4. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    Hi. thanks for reply.

    Nope.
    Autorefresh is enabled, but packages does not resolving.
    Unity3d 2019.4.21
     
  5. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    it's start resolving when i change foces to another app and back.
     
  6. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    this code does not working in unity 2019.4.21 but works in 2019.4.18
    package manifest does not reload

    Code (CSharp):
    1.  
    2.  
    3. private static string GetManifestPath()
    4. {
    5.     return (Directory.GetCurrentDirectory() + "\\Packages\\manifest.json").Replace('\\',
    6.         Path.DirectorySeparatorChar);
    7. }
    8.  
    9. private void SaveUnityManifest(JsonObject json)
    10. {
    11.     var str = json.ToString();
    12.     File.WriteAllText(GetManifestPath(), str);
    13.     AssetDatabase.Refresh();
    14. }
    15.  
     
  7. Davidtr_Unity

    Davidtr_Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    34
    Hi,

    Thank you for the detailed report. You are correct that AssetDatabase.Refresh no longer forces a resolve operation in the latest 2019.4 release. This was changed because forcing a resolve operation directly from managed code (C#) could break the import process in some scenarios. The safer, and recommended way to alter the manifest is to use our public C# API to add and remove packages, or to rely on the Auto-Refresh behavior when focusing the editor Window, if you plan to modify the manifest directly.

    Please note that we reworked some of this logic in 2020.1.x, and as a result this allowed us to make the Resolve method public. That being said, I would not recommend altering the manifest file directly through the code. If the reason you need to edit the manifest directly is caused by a gap in our API, please feel free to share your specific use-case so that we may remedy it in a future update, and maybe offer you a better alternative in the meantime.

    I hope this was helpful.
     
  8. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    Hi! Thank you so much
    This is exactly what I wanted to know.

    We we use a lot package manager.
    Having at least 120 custom packages for our sdk.
    And every day make modifications.

    Default package manager have a few disadvantages.
    it mainly concerns development tools.

    1. cannot load package info in one web request (for all packages of custom scope
    2. package embedding, modifying and uploading is too difficult
    3. have no notifications about concurrent package embedding

    We have our custom manager with this useful things.
     
    Last edited: Mar 22, 2021
    galford likes this.