Client reported about unsuccessful installation of the product, and I modified inline Powershell script to debug what's wrong.
It turned out that AI_SetMsiProperty didn't set property 'LEGACY_PRODUCT_CODE_FOUND' during script execution though AI_SetMsiProperty had been definitely reached. This property is required to decide if 'UninstallPreviousVersions' custom action should be triggered.
The error occurs only on one of the client’s machines; I could not reproduce it myself.
AI version: 20.9.1
DetectLegacyVersions Powershell script:
Code: Select all
Param($old_products, $old_version_threshold)
try {
Write-Host "Old products: '$old_products'"
$old_products = $old_products -split ';' | Where-Object { -not [string]::IsNullOrEmpty($_) }
if ($old_products.Count -eq 0) {
AI_SetMsiProperty LEGACY_PRODUCT_CODE_FOUND "0"
Write-Host "Old products not found"
return
}
$oldVersionThreshold = [System.Version]::new($old_version_threshold)
$uninstall32Key = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{*}"
$appsInfo = Get-ItemProperty -Path $uninstall32Key `
| Select-Object `
@{Name = 'Name'; Expression = { $_.DisplayName } },
@{Name = 'Version'; Expression = { $_.DisplayVersion } },
@{Name = 'ProductCode'; Expression = { $_.PSChildName } }
$searchedOldProducts = $appsInfo `
| Where-Object -FilterScript {
$old_products -contains $_.ProductCode -and [System.Version]::new($_.Version) -lt $oldVersionThreshold
}
if (@($searchedOldProducts).Count -eq 0) {
AI_SetMsiProperty LEGACY_PRODUCT_CODE_FOUND "0"
Write-Host "Legacy products not found"
} else {
AI_SetMsiProperty LEGACY_PRODUCT_CODE_FOUND "1"
Write-Host "Detected legacy products"
$searchedOldProducts | Format-Table
}
}
catch {
$exceptionInfo = $_.Exception
throw
}
finally {
if ($null -eq $exceptionInfo) {
$found = AI_GetMsiProperty LEGACY_PRODUCT_CODE_FOUND
if ($found -ne "1" -and $found -ne "0") {
throw "Property 'LEGACY_PRODUCT_CODE_FOUND' is not assigned"
}
}
}
MSI (c) (CC:3C) [08:20:17:293]: Doing action: DetectLegacyVersions
Action 08:20:17: DetectLegacyVersions.
Action start 08:20:17: DetectLegacyVersions.
MSI (c) (CC:4C) [08:20:17:297]: Invoking remote custom action. DLL: C:\Users\someuser\AppData\Local\Temp\MSI2AE.tmp, Entrypoint: RunPowerShellScript
[INFO] PowerShell script preferred invocation folder:
Dumping PowerShell invoke log ...
--> Found PowerShell path: C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
--> PowerShell Script Execution Result Code: 574
--> PowerShell Script Execution log:
Old products: ''
Old products not found
ERROR: Property 'LEGACY_PRODUCT_CODE_FOUND' is not assigned