Skip to content

Commit 0228fbf

Browse files
authored
Fixed -Check/InstallVCLibs error if multiple versions of a package are installed (#5833)
1 parent da06cf4 commit 0228fbf

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

tools/DevCheck/DevCheck.ps1

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -853,13 +853,13 @@ function Install-VCLibsAppx
853853
[string]$architecture
854854
)
855855

856-
$install = 0
856+
$install_issues = 0
857857

858-
$package = Get-AppxPackage $name | Where-Object Architecture -eq $architecture
859-
if (-not $package)
858+
$packages = Get-AppxPackage $name | Where-Object Architecture -eq $architecture
859+
if (-not $packages)
860860
{
861861
Write-Host "...$name $($architecture) not installed"
862-
$install++
862+
$install_issues++
863863
$identity = $null
864864
}
865865
else
@@ -872,35 +872,43 @@ function Install-VCLibsAppx
872872
$stream.Close()
873873
$zip.Dispose()
874874
$xml = [xml]$manifest
875-
#$identity = $xml.selectSingleNode("/*[local-name()='Package']/*[local-name='Identity']")
876875
$identity = $xml.documentElement.Identity
877-
$appx_version_fields = Parse-DotQuadVersion $identity.Version
878-
$appx_version = "{0:X04}.{1:X04}.{2:X04}.{3:X04}" -f $appx_version_fields
876+
$appx_version = $identity.Version
877+
$appx_version_fields = Parse-DotQuadVersion $appx_version
878+
$appx_version_comparable = "{0:X04}.{1:X04}.{2:X04}.{3:X04}" -f $appx_version_fields
879879

880-
if ($package)
880+
$max_found_version = $null
881+
$max_found_version_comparable = $null
882+
ForEach ($package in $packages)
881883
{
882-
$package_version_fields = Parse-DotQuadVersion $package.Version
883-
$package_version = "{0:X04}.{1:X04}.{2:X04}.{3:X04}" -f $package_version_fields
884-
885-
if ($package_version -ge $appx_version)
884+
if (($max_found_version_comparable -eq $null) -or ($max_found_version_comparable -lt $appx_version))
885+
{
886+
$max_found_version = $package.Version
887+
$version_fields = Parse-DotQuadVersion $max_found_version
888+
$max_found_version_comparable = "{0:X04}.{1:X04}.{2:X04}.{3:X04}" -f $version_fields
889+
}
890+
}
891+
if ($max_found_version)
892+
{
893+
if ($max_found_version_comparable -ge $appx_version_comparable)
886894
{
887-
Write-Host "...$($name) $($architecture): Latest version $($package.Version) installed"
895+
Write-Host "...$($name) $($architecture): Latest version $($max_found_version) installed"
888896
}
889897
else
890898
{
891-
Write-Host "...$($name) $($architecture): $($package.Version) installed but newer version $($identity.Version) available"
892-
$install++
899+
Write-Host "...$($name) $($architecture): $($max_found_version) installed but newer version $($appx_version) available"
900+
$install_issues++
893901
}
894902
}
895903
}
896904

897905
if ($InstallVCLibs)
898906
{
899-
if ($install)
907+
if ($install_issues)
900908
{
901909
if ($identity)
902910
{
903-
Write-Host "...Installing $name $($architecture) $($identity.Version)..."
911+
Write-Host "...Installing $name $($architecture) $($appx_version)..."
904912
}
905913
else
906914
{
@@ -911,9 +919,9 @@ function Install-VCLibsAppx
911919
}
912920
else
913921
{
914-
$global:issues += $install
922+
$global:issues += $install_issues
915923
}
916-
return $install -eq 0
924+
return $install_issues -eq 0
917925
}
918926

919927
function Install-VCLibs
@@ -941,7 +949,6 @@ function Install-VCLibs
941949
Write-Host "Installing VCLibs MSIX packages..."
942950
$cpu = Get-CpuArchitecture
943951

944-
945952
Install-VCLibsAppx (Join-Path $path 'Retail\x86\Microsoft.VCLibs.x86.14.00.appx') 'Microsoft.VCLibs.140.00' 'x86'
946953
Install-VCLibsAppx (Join-Path $path 'Debug\x86\Microsoft.VCLibs.x86.Debug.14.00.appx') 'Microsoft.VCLibs.140.00.Debug' 'x86'
947954
Install-VCLibsAppx (Join-Path $path_desktop 'Retail\x86\Microsoft.VCLibs.x86.14.00.Desktop.appx') 'Microsoft.VCLibs.140.00.UWPDesktop' 'x86'

0 commit comments

Comments
 (0)