Skip to content

NuGet 2 mirror command does not replace missing packages #1574

@jc1001

Description

@jc1001

Hi there,

I've found an issue while using the "mirror" command (NuGet.ServerExtensions.dll) in NuGet 2 to mirror from several remote repositories to a local path.

The problem occurred in the following scenario:

  • Package A has a dependency on package B.
  • Using the mirror command on package A (with the default DependenciesMode option), mirror pulls both package A and B as expected.
  • I then went and deleted package B from the local path and ran the command again.
  • According to the command-line output B is already present on the local path and it wasn't pulled again.
  • If I delete A and B and run the command again, everything works as expected (both packages are pulled again).

The problem seems to be related to the following lines of code in "PackageMirrorer.cs" (from line 99):
https://github.com/NuGet/NuGet2/blob/dev/src/CommandLine.ServerExtensions/PackageMirrorer.cs

foreach (var p in packagesToMirror)
{
  if (TargetRepository.Exists(package))
  ...

Shouldn't this be:

foreach (var p in packagesToMirror)
{
  if (TargetRepository.Exists(p))
  ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions