Skip to content

Commit ad1dde4

Browse files
authored
Added -CheckVCLibs and -InstallVCLibs options (#5821)
New options: * -CheckVCLibs - check if the Microsoft.VCLibs*14.00*.msix packages need to be installed * -InstallVCLibs - install the Microsoft.VCLibs*14.00*.msix packages (if necessary) -CheckVCLibs occurs by default (like other -Check... options) -FixAll includes InstallVCLibs
1 parent 229ce33 commit ad1dde4

1 file changed

Lines changed: 142 additions & 1 deletion

File tree

tools/DevCheck/DevCheck.ps1

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
.PARAMETER FixLongPath
5656
Enable LongPath support if necessary.
5757
58+
.PARAMETER InstallVCLibs
59+
Install VCLibs MSIX packages.
60+
5861
.PARAMETER InstallWindowsSDK
5962
Download and install Windows Platform SDKs (if necessary).
6063
@@ -145,6 +148,8 @@ Param(
145148

146149
[Switch]$CheckTestPfx=$false,
147150

151+
[Switch]$CheckVCLibs=$false,
152+
148153
[Switch]$CheckVisualStudio=$false,
149154

150155
[Switch]$CheckWindowsSDK=$false,
@@ -155,6 +160,8 @@ Param(
155160

156161
[Switch]$FixLongPath=$false,
157162

163+
[Switch]$InstallVCLibs=$false,
164+
158165
[Switch]$InstallWindowsSDK=$false,
159166

160167
[Switch]$NoInteractive=$false,
@@ -233,6 +240,8 @@ $global:windows_sdks = (('10.0.17763.0', 'https://go.microsoft.com/fwlink/p/?Lin
233240
$global:nuget_restore_filenames = ('.')
234241
#--------------------------------------
235242

243+
$null = [Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
244+
236245
function Get-Issues
237246
{
238247
return $global:issues + $global:issues_valid_test_pfx_thumbprint_not_found + $global:issues_valid_test_certificate_thumbprint_not_found + $global:issues_nuget_exe_not_found
@@ -836,6 +845,132 @@ function Test-WindowsSDKInstall
836845
return $found
837846
}
838847

848+
function Install-VCLibsAppx
849+
{
850+
param(
851+
[string]$file,
852+
[string]$name,
853+
[string]$architecture
854+
)
855+
856+
$install = 0
857+
858+
$package = Get-AppxPackage $name | Where-Object Architecture -eq $architecture
859+
if (-not $package)
860+
{
861+
Write-Host "...$name $($architecture) not installed"
862+
$install++
863+
$identity = $null
864+
}
865+
else
866+
{
867+
$zip = [IO.Compression.ZipFile]::OpenRead($file)
868+
$stream = $zip.GetEntry('AppxManifest.xml').Open()
869+
$reader = New-Object IO.StreamReader($stream)
870+
$manifest = $reader.ReadToEnd()
871+
$reader.Close()
872+
$stream.Close()
873+
$zip.Dispose()
874+
$xml = [xml]$manifest
875+
#$identity = $xml.selectSingleNode("/*[local-name()='Package']/*[local-name='Identity']")
876+
$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
879+
880+
if ($package)
881+
{
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)
886+
{
887+
Write-Host "...$($name) $($architecture): Latest version $($package.Version) installed"
888+
}
889+
else
890+
{
891+
Write-Host "...$($name) $($architecture): $($package.Version) installed but newer version $($identity.Version) available"
892+
$install++
893+
}
894+
}
895+
}
896+
897+
if ($InstallVCLibs)
898+
{
899+
if ($install)
900+
{
901+
if ($identity)
902+
{
903+
Write-Host "...Installing $name $($architecture) $($identity.Version)..."
904+
}
905+
else
906+
{
907+
Write-Host "...Installing $name $($architecture)..."
908+
}
909+
Add-AppxPackage $file
910+
}
911+
}
912+
else
913+
{
914+
$global:issues += $install
915+
}
916+
return $install -eq 0
917+
}
918+
919+
function Install-VCLibs
920+
{
921+
$extension_sdks = Join-Path ${Env:ProgramFiles(x86)} 'Microsoft SDKs\Windows Kits\10\ExtensionSDKs'
922+
$path = Join-Path $extension_sdks 'Microsoft.VCLibs\14.0\Appx'
923+
$path_desktop = Join-Path $extension_sdks 'Microsoft.VCLibs.Desktop\14.0\Appx'
924+
$found = Test-Path $path -PathType Container
925+
$found_desktop = Test-Path $path_desktop -PathType Container
926+
if (-not $found)
927+
{
928+
Write-Host "...ERROR: Microsoft.VCLibs.*.14.00.appx not found or valid." -ForegroundColor Red -BackgroundColor Black
929+
$global:issues++
930+
}
931+
if (-not $found_desktop)
932+
{
933+
Write-Host "...ERROR: Microsoft.VCLibs.*.14.00.Desktop.appx not found or valid." -ForegroundColor Red -BackgroundColor Black
934+
$global:issues++
935+
}
936+
if ((-not $found) -or (-not $found_desktop))
937+
{
938+
return $false
939+
}
940+
941+
Write-Host "Installing VCLibs MSIX packages..."
942+
$cpu = Get-CpuArchitecture
943+
944+
945+
Install-VCLibsAppx (Join-Path $path 'Retail\x86\Microsoft.VCLibs.x86.14.00.appx') 'Microsoft.VCLibs.140.00' 'x86'
946+
Install-VCLibsAppx (Join-Path $path 'Debug\x86\Microsoft.VCLibs.x86.Debug.14.00.appx') 'Microsoft.VCLibs.140.00.Debug' 'x86'
947+
Install-VCLibsAppx (Join-Path $path_desktop 'Retail\x86\Microsoft.VCLibs.x86.14.00.Desktop.appx') 'Microsoft.VCLibs.140.00.UWPDesktop' 'x86'
948+
Install-VCLibsAppx (Join-Path $path_desktop 'Debug\x86\Microsoft.VCLibs.x86.Debug.14.00.Desktop.appx') 'Microsoft.VCLibs.140.00.Debug.UWPDesktop' 'x86'
949+
950+
if (($cpu -eq 'x64') -or ($cpu -eq 'arm64'))
951+
{
952+
Install-VCLibsAppx (Join-Path $path 'Retail\x64\Microsoft.VCLibs.x64.14.00.appx') 'Microsoft.VCLibs.140.00' 'x64'
953+
Install-VCLibsAppx (Join-Path $path 'Debug\x64\Microsoft.VCLibs.x64.Debug.14.00.appx') 'Microsoft.VCLibs.140.00.Debug' 'x64'
954+
Install-VCLibsAppx (Join-Path $path_desktop 'Retail\x64\Microsoft.VCLibs.x64.14.00.Desktop.appx') 'Microsoft.VCLibs.140.00.UWPDesktop' 'x64'
955+
Install-VCLibsAppx (Join-Path $path_desktop 'Debug\x64\Microsoft.VCLibs.x64.Debug.14.00.Desktop.appx') 'Microsoft.VCLibs.140.00.Debug.UWPDesktop' 'x64'
956+
}
957+
958+
if ($cpu -eq 'arm64')
959+
{
960+
Install-VCLibsAppx (Join-Path $path 'Retail\arm64\Microsoft.VCLibs.arm64.14.00.appx') 'Microsoft.VCLibs.140.00' 'arm64'
961+
Install-VCLibsAppx (Join-Path $path 'Debug\arm64\Microsoft.VCLibs.arm64.Debug.14.00.appx') 'Microsoft.VCLibs.140.00.Debug' 'arm64'
962+
Install-VCLibsAppx (Join-Path $path_desktop 'Retail\arm64\Microsoft.VCLibs.arm64.14.00.Desktop.appx') 'Microsoft.VCLibs.140.00.UWPDesktop' 'arm64'
963+
Install-VCLibsAppx (Join-Path $path_desktop 'Debug\arm64\Microsoft.VCLibs.arm64.Debug.14.00.Desktop.appx') 'Microsoft.VCLibs.140.00.Debug.UWPDesktop' 'arm64'
964+
}
965+
966+
return $true
967+
}
968+
969+
function Test-VCLibsInstall
970+
{
971+
$null = Install-VCLibs
972+
}
973+
839974
function Test-DevTestPfx
840975
{
841976
if ($Clean -eq $true)
@@ -1875,7 +2010,7 @@ $null = Get-UserSettings
18752010
$remove_any = ($RemoveAll -eq $true) -or ($RemoveTaefService -eq $true) -or ($RemoveTestCert -eq $true) -or ($RemoveTestCert -eq $true)
18762011
if (($remove_any -eq $false) -And ($CheckTAEFService -eq $false) -And ($StartTAEFService -eq $false) -And
18772012
($StopTAEFService -eq $false) -And ($CheckTestCert -eq $false) -And ($CheckTestPfx -eq $false) -And
1878-
($CheckVisualStudio -eq $false) -And ($CheckWindowsSDK -eq $false) -And
2013+
($CheckVCLibs -eq $false) -And ($CheckVisualStudio -eq $false) -And ($CheckWindowsSDK -eq $false) -And
18792014
($CheckDependencies -eq $false) -And ($SyncDependencies -eq $false) -And
18802015
($CheckNugetExe -eq $false) -And ($NugetExeUpdate -eq $false) -And
18812016
($CheckDeveloperMode -eq $false) -And ($ShowSystemInfo -eq $false))
@@ -1889,6 +2024,7 @@ if ($SyncDependencies -eq $true)
18892024
if ($FixAll -eq $true)
18902025
{
18912026
$FixLongPath = $true
2027+
$InstallVCLibs = $true
18922028
$InstallWindowsSDK = $true
18932029
}
18942030

@@ -1915,6 +2051,11 @@ if (($CheckAll -ne $false) -Or ($CheckWindowsSDK -ne $false))
19152051
}
19162052
}
19172053

2054+
if (($CheckAll -ne $false) -Or ($CheckVCLibs -ne $false))
2055+
{
2056+
$ok = Test-VCLibsInstall
2057+
}
2058+
19182059
if (($CheckAll -ne $false) -Or ($CheckVisualStudio -ne $false))
19192060
{
19202061
$ok = Test-VisualStudio2022Install

0 commit comments

Comments
 (0)