@@ -56,7 +56,6 @@ internal class InstallHelper
5656 private bool _savePkg ;
5757 private string _runtimeIdentifier ;
5858 private string _targetFramework ;
59- private bool _mergeFilteredContent ;
6059 List < string > _pathsToSearch ;
6160 List < string > _pkgNamesToInstall ;
6261 private string _tmpPath ;
@@ -410,7 +409,8 @@ private void MoveFilesIntoInstallPath(
410409 string installPath ,
411410 string newVersion ,
412411 string moduleManifestVersion ,
413- string scriptPath )
412+ string scriptPath ,
413+ bool mergeFilteredContent )
414414 {
415415 _cmdletPassedIn . WriteDebug ( "In InstallHelper::MoveFilesIntoInstallPath()" ) ;
416416 // Creating the proper installation path depending on whether pkg is a module or script
@@ -433,7 +433,7 @@ private void MoveFilesIntoInstallPath(
433433 Directory . CreateDirectory ( newPathParent ) ;
434434 Utils . MoveDirectory ( tempModuleVersionDir , finalModuleVersionDir ) ;
435435 }
436- else if ( _mergeFilteredContent && Directory . Exists ( finalModuleVersionDir ) )
436+ else if ( mergeFilteredContent && Directory . Exists ( finalModuleVersionDir ) )
437437 {
438438 // Copy only new TFM/RID content into the existing install
439439 _cmdletPassedIn . WriteVerbose ( $ "Merging additional platform content from '{ tempModuleVersionDir } ' into '{ finalModuleVersionDir } '") ;
@@ -570,6 +570,8 @@ private List<PSResourceInfo> InstallPackages(
570570 continue ;
571571 }
572572
573+ bool mergeFilteredContent = false ;
574+
573575 // Check to see if the pkg is already installed (unless -Reinstall was specified).
574576 if ( ! _reinstall && _packagesOnMachine . Contains ( $ "{ pkgToInstall . Name } { pkgVersion } ") )
575577 {
@@ -580,7 +582,7 @@ private List<PSResourceInfo> InstallPackages(
580582 {
581583 _cmdletPassedIn . WriteVerbose ( $ "Resource '{ pkgToInstall . Name } ' with version '{ pkgVersion } ' is already installed. " +
582584 $ "Proceeding to merge additional platform content (TargetFramework='{ _targetFramework } ', RuntimeIdentifier='{ _runtimeIdentifier } ').") ;
583- _mergeFilteredContent = true ;
585+ mergeFilteredContent = true ;
584586 }
585587 else
586588 {
@@ -606,7 +608,8 @@ private List<PSResourceInfo> InstallPackages(
606608 {
607609 PkgToInstall = pkgToInstall ,
608610 PkgVersion = pkgVersion ,
609- TempInstallPath = CreateInstallationTempPath ( )
611+ TempInstallPath = CreateInstallationTempPath ( ) ,
612+ MergeFilteredContent = mergeFilteredContent
610613 } ) ;
611614 }
612615
@@ -659,7 +662,11 @@ private List<PSResourceInfo> InstallPackages(
659662
660663 // Parent package and dependencies are now installed to temp directory.
661664 // Try to move all package directories from temp directory to final destination.
662- if ( ! TryMoveInstallContent ( workItem . TempInstallPath , scope , workItem . PackagesHash ) )
665+ if ( ! TryMoveInstallContent (
666+ workItem . TempInstallPath ,
667+ scope ,
668+ workItem . PackagesHash ,
669+ workItem . MergeFilteredContent ) )
663670 {
664671 _cmdletPassedIn . WriteError ( new ErrorRecord (
665672 new InvalidOperationException ( ) ,
@@ -710,6 +717,7 @@ private sealed class ParentInstallWorkItem
710717 public string TempInstallPath ;
711718 public ConcurrentDictionary < string , Hashtable > PackagesHash ;
712719 public bool Succeeded ;
720+ public bool MergeFilteredContent ;
713721 public readonly ConcurrentQueue < ErrorRecord > ErrorMsgs = new ( ) ;
714722 public readonly ConcurrentQueue < string > WarningMsgs = new ( ) ;
715723 public readonly ConcurrentQueue < string > DebugMsgs = new ( ) ;
@@ -1410,16 +1418,12 @@ private bool TryExtractToDirectory(string zipPath, string extractPath, out Error
14101418
14111419 if ( ! string . IsNullOrEmpty ( _runtimeIdentifier ) )
14121420 {
1413- bool hasMatchingRid = archive . Entries . Any ( e =>
1414- RuntimePackageHelper . IsRidFolder ( e . FullName . Replace ( ' \\ ' , '/' ) . Split ( '/' ) [ 0 ] ) &&
1415- RuntimePackageHelper . ShouldIncludeEntry ( e . FullName , _runtimeIdentifier ) ) ;
1421+ IReadOnlyList < string > availableRids = RuntimePackageHelper . GetAvailableRidsFromArchive ( archive ) ;
1422+ bool hasMatchingRid = availableRids . Any ( rid =>
1423+ RuntimeIdentifierHelper . IsCompatibleRid ( rid , _runtimeIdentifier ) ) ;
14161424
14171425 if ( ! hasMatchingRid )
14181426 {
1419- var availableRids = archive . Entries
1420- . Select ( e => e . FullName . Replace ( '\\ ' , '/' ) . Split ( '/' ) [ 0 ] )
1421- . Where ( f => RuntimePackageHelper . IsRidFolder ( f ) )
1422- . Distinct ( StringComparer . OrdinalIgnoreCase ) ;
14231427 string available = string . Join ( ", " , availableRids ) ;
14241428 _cmdletPassedIn . WriteWarning (
14251429 $ "The specified RuntimeIdentifier '{ _runtimeIdentifier } ' was not found in this package. " +
@@ -1662,7 +1666,11 @@ private void WarnIfCrossLineageTfmSkipped(ZipArchive archive, NuGetFramework bes
16621666 /// <summary>
16631667 /// Moves package files/directories from the temp install path into the final install path location.
16641668 /// </summary>
1665- private bool TryMoveInstallContent ( string tempInstallPath , ScopeType scope , ConcurrentDictionary < string , Hashtable > packagesHash )
1669+ private bool TryMoveInstallContent (
1670+ string tempInstallPath ,
1671+ ScopeType scope ,
1672+ ConcurrentDictionary < string , Hashtable > packagesHash ,
1673+ bool mergeFilteredContent )
16661674 {
16671675 _cmdletPassedIn . WriteDebug ( "In InstallHelper::TryMoveInstallContent()" ) ;
16681676 foreach ( string pkgName in packagesHash . Keys )
@@ -1687,7 +1695,8 @@ private bool TryMoveInstallContent(string tempInstallPath, ScopeType scope, Conc
16871695 installPath ,
16881696 newVersion : pkgVersion , // would not have prerelease label in this string
16891697 moduleManifestVersion : pkgVersion ,
1690- scriptPath ) ;
1698+ scriptPath ,
1699+ mergeFilteredContent ) ;
16911700
16921701 _cmdletPassedIn . WriteVerbose ( $ "Successfully installed package '{ pkgName } ' to location '{ installPath } '") ;
16931702
0 commit comments