How can i resolve packages with api?

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.

only reflection?

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

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.

Hi. thanks for reply.

Nope.
Autorefresh is enabled, but packages does not resolving.
Unity3d 2019.4.21

it’s start resolving when i change foces to another app and back.

this code does not working in unity 2019.4.21 but works in 2019.4.18
package manifest does not reload

private static string GetManifestPath()
{
    return (Directory.GetCurrentDirectory() + "\\Packages\\manifest.json").Replace('\\',
        Path.DirectorySeparatorChar);
}

private void SaveUnityManifest(JsonObject json)
{
    var str = json.ToString();
    File.WriteAllText(GetManifestPath(), str);
    AssetDatabase.Refresh();
}

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.

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.

1 Like