@@ -787,16 +787,16 @@ private void RestoreProjects(IEnumerable<string> projects, out IEnumerable<strin
787787 [ GeneratedRegex ( @"^(.+)\.(\d+\.\d+\.\d+(-(.+))?)$" , RegexOptions . IgnoreCase | RegexOptions . Compiled | RegexOptions . Singleline ) ]
788788 private static partial Regex LegacyNugetPackage ( ) ;
789789
790- private void DownloadMissingPackages ( List < FileInfo > allFiles , ISet < string > dllPaths )
790+
791+ private static IEnumerable < string > GetRestoredPackageDirectoryNames ( DirectoryInfo root )
791792 {
792- var alreadyDownloadedPackages = Directory . GetDirectories ( packageDirectory . DirInfo . FullName )
793+ return Directory . GetDirectories ( root . FullName )
793794 . Select ( d => Path . GetFileName ( d ) . ToLowerInvariant ( ) ) ;
794- var notYetDownloadedPackages = fileContent . AllPackages
795- . Except ( alreadyDownloadedPackages )
796- . ToHashSet ( ) ;
795+ }
797796
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 ) ;
800800 foreach ( var oldPackageDirectory in oldPackageDirectories )
801801 {
802802 // 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
812812 continue ;
813813 }
814814
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 ) ;
817832 }
818833
819834 if ( notYetDownloadedPackages . Count == 0 )
0 commit comments