Last active
March 7, 2025 23:41
-
-
Save JimMoyle/55d37a8bf23acee4a2f0ad3b6ce6a74e to your computer and use it in GitHub Desktop.
Install MSIX frameworks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$frameWorkList = 'Microsoft.WindowsAppRuntime', 'Microsoft.UI.Xaml', 'Microsoft.VCLibs', 'Microsoft.NET.Native.Runtime', 'Microsoft.NET.Native.Framework', 'Microsoft.WindowsAppRuntime.CBS' | |
foreach ($framework in $frameWorkList) { | |
if($framework -eq 'Microsoft.WindowsAppRuntime') { | |
$download = 'Microsoft.WindowsAppSDK' | |
} | |
else{ | |
$download = $framework | |
} | |
$allPackageVersion = Find-Package $download -AllVersions | |
$sanitisedPackages = foreach ($package in $allPackageVersion) { | |
try { | |
$typeVersion = [version]$package.Version | |
$package | Add-Member -MemberType NoteProperty -Name Version -Value $typeVersion -Force | |
Write-Output $package | |
} | |
catch { | |
#Do nothing if we can't change version string to [version] type | |
} | |
} | |
$verGrouped = $sanitisedPackages.Version | Group-Object -Property Major, Minor | Select-Object Name | |
$latestOfEachMajorVer = foreach ($ver in $verGrouped) { | |
$verSplit = $ver.Name -split ', ' | |
$sanitisedPackages | | |
Where-Object { $_.Version.Major -eq $verSplit[0] -and $_.Version.Minor -eq $verSplit[1] } | | |
Sort-Object -Property Version -Descending | | |
Select-Object -First 1 | |
} | |
$savedFiles = $latestOfEachMajorVer | Save-Package -Path $ENV:TEMP -Force #-ErrorAction SilentlyContinue | |
$relevantFiles = $savedFiles | Where-Object { $_.Name -eq $download } | |
#Add-Type -AssemblyName System.IO.Compression.FileSystem | |
#Microsoft.WindowsAppRuntime | |
foreach ($file in $relevantFiles) { | |
$xmlFileInfo = [xml]$file.SwidTagText | |
$directory = (Join-Path $xmlFileInfo.SoftwareIdentity.Payload.Directory.location $xmlFileInfo.SoftwareIdentity.Payload.Directory.name) | |
$filePath = Join-Path $directory $file.PackageFilename | |
$destPath = Join-Path $ENV:TEMP $file.PackageFilename.TrimEnd(".nupkg") | |
New-Item -ItemType Directory -Path $destPath -Force | Out-Null | |
# Expand-Archive does not allow for files which are not zip files to be extracted, so we need to use the below line instead. | |
[System.IO.Compression.ZipFile]::ExtractToDirectory($filePath, $destPath, $true) | |
$typeVersion = [version]$file.Version | |
$truncatedVersion = $typeVersion.Major.ToString() + "." + $typeVersion.Minor.ToString() | |
$fileName = $framework + "." + $truncatedVersion + ".msix" | |
Add-AppxPackage (Join-Path $destPath "tools\MSIX\win10-x64\$fileName") | |
Add-AppxPackage (Join-Path $destPath "tools\MSIX\win10-x86\$fileName") | |
#Remove-Item $destPath -Recurse -Force | |
} | |
#$relevantFiles | Expand-Archive -DestinationPath $ENV:TEMP | |
#$latestOfEachMajorVer | Install-Package -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment