@@ -787,16 +787,16 @@ private void RestoreProjects(IEnumerable<string> projects, out IEnumerable<strin
787
787
[ GeneratedRegex ( @"^(.+)\.(\d+\.\d+\.\d+(-(.+))?)$" , RegexOptions . IgnoreCase | RegexOptions . Compiled | RegexOptions . Singleline ) ]
788
788
private static partial Regex LegacyNugetPackage ( ) ;
789
789
790
- private void DownloadMissingPackages ( List < FileInfo > allFiles , ISet < string > dllPaths )
790
+
791
+ private static IEnumerable < string > GetRestoredPackageDirectoryNames ( DirectoryInfo root )
791
792
{
792
- var alreadyDownloadedPackages = Directory . GetDirectories ( packageDirectory . DirInfo . FullName )
793
+ return Directory . GetDirectories ( root . FullName )
793
794
. Select ( d => Path . GetFileName ( d ) . ToLowerInvariant ( ) ) ;
794
- var notYetDownloadedPackages = fileContent . AllPackages
795
- . Except ( alreadyDownloadedPackages )
796
- . ToHashSet ( ) ;
795
+ }
797
796
798
- var oldPackageDirectories = Directory . GetDirectories ( legacyPackageDirectory . DirInfo . FullName )
799
- . Select ( d => Path . GetFileName ( d ) . ToLowerInvariant ( ) ) ;
797
+ private IEnumerable < string > GetRestoredLegacyPackageNames ( )
798
+ {
799
+ var oldPackageDirectories = GetRestoredPackageDirectoryNames ( legacyPackageDirectory . DirInfo ) ;
800
800
foreach ( var oldPackageDirectory in oldPackageDirectories )
801
801
{
802
802
// nuget install restores packages to 'packagename.version' folders (dotnet restore to 'packagename/version' folders)
@@ -812,8 +812,23 @@ private void DownloadMissingPackages(List<FileInfo> allFiles, ISet<string> dllPa
812
812
continue ;
813
813
}
814
814
815
- var packageName = match . Groups [ 1 ] . Value . ToLowerInvariant ( ) ;
816
- notYetDownloadedPackages . Remove ( packageName ) ;
815
+ yield return match . Groups [ 1 ] . Value . ToLowerInvariant ( ) ;
816
+ }
817
+ }
818
+
819
+ private void DownloadMissingPackages ( List < FileInfo > allFiles , ISet < string > dllPaths )
820
+ {
821
+ var alreadyDownloadedPackages = GetRestoredPackageDirectoryNames ( packageDirectory . DirInfo ) ;
822
+ var alreadyDownloadedLegacyPackages = GetRestoredLegacyPackageNames ( ) ;
823
+
824
+ var notYetDownloadedPackages = new HashSet < string > ( fileContent . AllPackages ) ;
825
+ foreach ( var alreadyDownloadedPackage in alreadyDownloadedPackages )
826
+ {
827
+ notYetDownloadedPackages . Remove ( alreadyDownloadedPackage ) ;
828
+ }
829
+ foreach ( var alreadyDownloadedLegacyPackage in alreadyDownloadedLegacyPackages )
830
+ {
831
+ notYetDownloadedPackages . Remove ( alreadyDownloadedLegacyPackage ) ;
817
832
}
818
833
819
834
if ( notYetDownloadedPackages . Count == 0 )
0 commit comments