From 0e53e43c77b98afb3188006c1f24374857324d82 Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Mon, 21 Jul 2025 19:12:10 -0700 Subject: [PATCH] Improves Win32 app detection and logging Refines the logic for verifying existing Win32 applications by checking for architecture-specific names (x86, x64, arm64). Enhances validation by ensuring the application folder contains files of a sufficient size, not just that the folder exists. Adds more detailed logging to aid in troubleshooting cases where an app is not found or its content is missing. --- FFUDevelopment/BuildFFUVM.ps1 | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/FFUDevelopment/BuildFFUVM.ps1 b/FFUDevelopment/BuildFFUVM.ps1 index 24ebe7f..2f62aee 100644 --- a/FFUDevelopment/BuildFFUVM.ps1 +++ b/FFUDevelopment/BuildFFUVM.ps1 @@ -4158,17 +4158,38 @@ if ($InstallApps) { # Check Win32 apps regardless of source if ($wingetAppsJson) { - $wingetApp = $wingetAppsJson | Where-Object { $_.Name -eq $app.name } + # Check for exact match or architecture-specific entries + $wingetApp = $wingetAppsJson | Where-Object { + $_.Name -eq $app.name -or + $_.Name -eq "$($app.name) (x86)" -or + $_.Name -eq "$($app.name) (x64)" -or + $_.Name -eq "$($app.name) (arm64)" + } if ($wingetApp) { # Verify content exists in Win32 folder $appFolder = Join-Path -Path "$AppsPath\Win32" -ChildPath $app.name if (Test-Path -Path $appFolder) { - $folderSize = (Get-ChildItem -Path $appFolder -Recurse | Measure-Object -Property Length -Sum).Sum - if ($folderSize -gt 1MB) { - $appFound = $true - WriteLog "Found existing Win32 app: $($app.name)" + # Check for actual files in the folder or its subdirectories + $allFiles = Get-ChildItem -Path $appFolder -Recurse -File -ErrorAction SilentlyContinue + + if ($allFiles) { + # Verify actual content size + $folderSize = ($allFiles | Measure-Object -Property Length -Sum).Sum + if ($folderSize -gt 1MB) { + $appFound = $true + WriteLog "Found existing Win32 app: $($app.name) (Size: $([math]::Round($folderSize/1MB, 2)) MB)" + } + else { + WriteLog "Win32 app folder exists but content is too small: $($app.name) (Size: $([math]::Round($folderSize/1MB, 2)) MB)" + } } + else { + WriteLog "Win32 app folder exists but contains no files: $($app.name)" + } + } + else { + WriteLog "Win32 app folder does not exist: $($app.name)" } } }