Search code examples
nugetartifactoryjfrog-cli

Use jfrog-cli to recursively download nuget package along with it's dependencies


I have the following structure in Jfrog Artifactory for NuGet repository

nuget-virtual-repo
                |__package1.1.0.nupkg
                |__package2.2.0.nupkg
                |__package3.3.0.nupkg

Now package1.1.0 have a dependency on package2.2.0 and it is mentioned in it nuget.dependency property:

nuget.dependency package2:2.0:

Also package2.2.0 have a dependency on package3.3.0 and it is mentioned in it's nuget.dependency property: nuget.dependency package3:3.0:

Now when I try to download package1.1.0 using jfrog-cli it does not downloads the other dependent package along with it:

jfrog-cli.exe rt dl --apikey=<API_KEY> --url=https://<artifactory_url> --detailed-summary nuget-virtual-repo/package1.1.0.nupkg

Output:

{
  "status": "success",
  "totals": {
    "success": 1,
    "failure": 0
  },
  "files": [
    {
      "source": "https://<artifactory_url>/nuget-virtual-repo/package1.1.0.nupkg",
      "target": "package1.1.0.nupkg"
    }
  ]
}

I am using spec file also with this inside but here also it download only 1 package:

'files': [
                {
                    'target': 'C:\JfrogCli',
                    'pattern': 'nuget-virtual-repo/*',
                    'props': 'nuget.id=package1;nuget.version=1.0',
                    'limit': 1,
                    'sortOrder': 'desc',
                    'sortBy': ['created']
                }
         ]

What I want is to download the dependencies recursively i.e. it should download package2.2.0.nupkg and package3.3.0.nupkg. I check the documentation but didn't found any flag to do that. Is there anything I can change maybe in spec file to download the dependencies without mentioning them explicitly?


Solution

  • you cannot replace the dependencecy management logic implemented by nuget with only the JFrog cli.

    While JFrog cli can be used to authenticate on artifactory and gather metadata during resolution and uploads of artefacts you still need the nuget (or .net core) client to interact with the nuget api exposed by the repository and get through the dependency graph of requested packages

    What you can do is to use the JFrog cli with native client as documented here : https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-BuildingNuGetPackages

    jfrog rt nugetc --server-id-resolve=<artifactoryServerID> --repo-resolve=nuget-virtual-repo
    

    and then

    jfrog rt nuget install package1 -Version 1.0
    

    This should install all transitive dependencies