Add zip extraction and improve UWP app detection

Enhances the application download logic to automatically extract zip archives. This allows for handling packages that are delivered in a compressed format.

Improves the reliability of identifying UWP applications by iterating through all downloaded files instead of checking only the first one. This prevents errors when multiple files are present after download or extraction.
This commit is contained in:
rbalsleyMSFT
2025-07-22 16:00:11 -07:00
parent 1b80d008ef
commit 298809686b
@@ -131,11 +131,30 @@ function Get-Application {
WriteLog "$AppName ($arch) downloaded to $appFolderPath"
# Handle winget source apps that have appx, appxbundle, msix, or msixbundle extensions but were downloaded to the Win32 folder
$installerPath = Get-ChildItem -Path "$appFolderPath\*" -Exclude "*.yaml", "*.xml" -File -ErrorAction Stop
$uwpExtensions = @(".appx", ".appxbundle", ".msix", ".msixbundle")
# Handle zip files
$zipFile = Get-ChildItem -Path $appFolderPath -Filter "*.zip" -File -ErrorAction SilentlyContinue
if ($zipFile) {
WriteLog "Found zip file: $($zipFile.FullName). Extracting..."
Expand-Archive -Path $zipFile.FullName -DestinationPath $appFolderPath -Force
WriteLog "Extraction complete. Removing zip file."
Remove-Item -Path $zipFile.FullName -Force
WriteLog "Zip file removed."
}
if ($uwpExtensions -contains $installerPath.Extension -and $appFolderPath -match 'Win32') {
# Handle winget source apps that have appx, appxbundle, msix, or msixbundle extensions but were downloaded to the Win32 folder
$installerFiles = Get-ChildItem -Path "$appFolderPath\*" -Exclude "*.yaml", "*.xml" -File -ErrorAction SilentlyContinue
$uwpExtensions = @(".appx", ".appxbundle", ".msix", ".msixbundle")
$isUwpApp = $false
if ($installerFiles) {
foreach ($file in $installerFiles) {
if ($uwpExtensions -contains $file.Extension) {
$isUwpApp = $true
break
}
}
}
if ($isUwpApp -and $appFolderPath -match 'Win32') {
# Handle UWP apps
$NewAppPath = "$AppsPath\MSStore\$AppName"
WriteLog "$AppName is a UWP app. Moving to $NewAppPath"