emgarten/NuGet.CatalogReader

Support including dependencies when specifying Ids to include

Closed this issue · 9 comments

I haven't found a good tool to do this yet but I would love for there to be an option like "--include-dependencies" that when combined with "-i" would pull down the whole chain of dependencies for any included id. I work on an isolated network and mirroring the entire repository is possibly overkill so it would be great if you supported this. It could even go one step further and allow you to specify the target platform(s) for which to pull the dependencies.

Example:

nugetmirror nupkgs https://api.nuget.org/v3/index.json -o c:\packages -i BenchmarkDotnet --include-dependencies netcoreapp11,netframework46

By target platforms do you mean runtimes? Are you restoring PackageReference projects or packages.config projects?

I am testing nugetmirror at the moment in the hope that I can mirror some packages (with deps) locally and then upload them to our internal NuGet gallery (this is how we currently restrict packages). I ran similar to above command and started seeing lots of files being downloaded. So killed the command and ended up here only to realize deps are not fetched. So I just needed some clarification if you can answer please:

  1. There is no way to get specific packages without first fetching registration blobs. Is this correct?
  2. Even if I let the command run and download all registration blobs, the tool will fetch the required packages but not the deps, right?

There is no way to get specific packages without first fetching registration blobs. Is this correct?

Registration blobs are used to discover all versions of the package, it could be done using flatcontainer files instead.

Even if I let the command run and download all registration blobs, the tool will fetch the required packages but not the deps, right?

The current behavior is that only the specified packages will be downloaded, but a feature could be added to include dependencies. The dependencies are listed in the registration blobs, so it would be a fairly straight forward change.

Thanks Justin. In the meantime I will use 'nuget install' which fetches the deps. I like this tool so adding dependencies feature will be good plus flatcontainer (which I assume will make fetching quicker). On a side note, not sure why 'mirror' command was deprecated in NuGet only to be reincarnated as nugetmirror. IMHO nugetmirror should be part of nuget.exe!

Note: what I discovered is that 'nuget install [package name] -version 1.2.3' does fetch deps but not the case when using 'nuget install packages.config'. This dichotomy is little unhelpful!

nuget install on a package.config file is identical to nuget restore packages.config, I think it is legacy behavior from before restore existed.

I'll keep this issue open to track support for including dependencies during mirroring.

I am also willing to take a PR for this feature 🍰

Yes please keep this open for tracking purposes. It would be great to see the feature implemented. What would be also awesome is to have this feature directly in NuGet Gallery where users can mirror using the GUI. Perhaps this is would be too much to ask?

Take a look at https://github.com/praeclarum/FuGetGallery for an alternative NuGet Gallery

@emgarten I see this was closed as completed, but in the latest version of NuGetMirror tool, I do not see this feature. How may I take advantage of how was this work completed?