From 298809686b9ba6181fe48b0e0462ba94223ff315 Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:00:11 -0700 Subject: [PATCH] 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. --- .../FFU.Common/FFU.Common.Winget.psm1 | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/FFUDevelopment/FFU.Common/FFU.Common.Winget.psm1 b/FFUDevelopment/FFU.Common/FFU.Common.Winget.psm1 index ee8aec5..9804978 100644 --- a/FFUDevelopment/FFU.Common/FFU.Common.Winget.psm1 +++ b/FFUDevelopment/FFU.Common/FFU.Common.Winget.psm1 @@ -130,12 +130,31 @@ function Get-Application { } WriteLog "$AppName ($arch) downloaded to $appFolderPath" + + # 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." + } # 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 + $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 ($uwpExtensions -contains $installerPath.Extension -and $appFolderPath -match 'Win32') { + if ($isUwpApp -and $appFolderPath -match 'Win32') { # Handle UWP apps $NewAppPath = "$AppsPath\MSStore\$AppName" WriteLog "$AppName is a UWP app. Moving to $NewAppPath"