Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Commit 34ce1f5

Browse files
committed
Download all packages even the ones that don't end up in the lock file
- This makes it so that we avoid hitting remote sources in the most common cases. #2061
1 parent d09f626 commit 34ce1f5

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/Microsoft.Framework.PackageManager/Restore/RestoreCommand.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,7 @@ private async Task<bool> RestoreForProject(string projectJsonPath, string rootDi
463463
{
464464
ForEach(context.Root, node =>
465465
{
466-
if (node == null ||
467-
node.LibraryRange == null ||
468-
node.Disposition == GraphNode.DispositionType.Rejected)
466+
if (node == null || node.LibraryRange == null)
469467
{
470468
return;
471469
}
@@ -503,16 +501,24 @@ private async Task<bool> RestoreForProject(string projectJsonPath, string rootDi
503501

504502
if (!isInstallItem && isRemote)
505503
{
504+
// It's ok to download rejected nodes so we avoid downloading them in the future
505+
// The trade off is that subsequent restores avoid going to any remotes
506506
installItems.Add(node.Item);
507507
}
508508

509-
var isGraphItem = graphItems.Any(item => item.Match.Library == node.Item.Match.Library);
510-
if (!isGraphItem)
509+
// Don't add rejected nodes since we only want to write reduced nodes
510+
// to the lock file
511+
if (node.Disposition != GraphNode.DispositionType.Rejected)
511512
{
512-
graphItems.Add(node.Item);
513-
}
513+
var isGraphItem = graphItems.Any(item => item.Match.Library == node.Item.Match.Library);
514514

515-
context.Libraries.Add(node.Item.Match.Library);
515+
if (!isGraphItem)
516+
{
517+
graphItems.Add(node.Item);
518+
}
519+
520+
context.Libraries.Add(node.Item.Match.Library);
521+
}
516522
});
517523
}
518524

@@ -1027,4 +1033,4 @@ private class TargetContext
10271033
public GraphNode Root { get; set; }
10281034
}
10291035
}
1030-
}
1036+
}

0 commit comments

Comments
 (0)