It needs to appear in the following scenarios:
- The appSettings.OnPremises.json file doesn't exist
- The appSettings.OnPremises.json file but it contains "http://localhost".
To that end, I created the following custom action, which sets the property NEED_API_URL_SET to "true" if either of the above conditions exist:
Code: Select all
param ($WinVolume)
$logPath = Join-Path $env:TEMP "ai_fqdn_check.log"
function Log($message) {
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
"$timestamp - $message" | Out-File -FilePath $logPath -Append -Encoding utf8
}
Log "=== Starting custom action to check appSettings.onPremises.json ==="
$IsIISEnabled = Get-WmiObject -Query "Select Name FROM Win32_Service where name='W3svc'"
if ($IsIISEnabled) {
Log "IIS service detected."
$wwwRootReg = Get-ItemProperty HKLM:\Software\Microsoft\INetStp -Name "PathWWWRoot"
$wwwRootPath = ($wwwRootReg.PathWWWRoot).TrimEnd("/","\")
Log "Resolved wwwRootPath from registry: $wwwRootPath"
} else {
Log "IIS not enabled, defaulting wwwRootPath."
$wwwRootPath = Join-Path $WinVolume 'inetpub\wwwroot'
Log "Using default wwwRootPath: $wwwRootPath"
}
AI_SetMsiProperty WWWROOT $wwwRootPath
AI_SetMsiProperty NEED_API_URL_SET ""
$targetPath = Join-Path $wwwRootPath "pkispotlight\appSettings.onPremises.json"
Log "Target file path: $targetPath"
if (Test-Path $targetPath) {
Log "File exists. Reading content..."
$content = Get-Content -Path $targetPath
if ($content | Where-Object { $_ -like '*http://localhost/*' }) {
Log "Found 'http://localhost' in file. Setting NEED_API_URL_SET to true."
AI_SetMsiProperty NEED_API_URL_SET "true"
} else {
Log "'http://localhost' not found in file."
}
} else {
Log "File does not exist. Setting NEED_API_URL_SET to true."
AI_SetMsiProperty NEED_API_URL_SET "true"
}
Log "=== Finished custom action ===`n"

(FolderDlg only needs to appear for new installs, so I can't bury ApiFqdnDlg under there.)
When I run the built MSI in upgrade mode, I can tell that my custom action is executing and working as expected because the log file is generated before the welcome screen appears:
Code: Select all
2025-05-29 12:42:10 - === Starting custom action to check appSettings.onPremises.json ===
2025-05-29 12:42:11 - IIS service detected.
2025-05-29 12:42:11 - Resolved wwwRootPath from registry: C:\inetpub\wwwroot
2025-05-29 12:42:11 - Target file path: C:\inetpub\wwwroot\pkispotlight\appSettings.onPremises.json
2025-05-29 12:42:11 - File exists. Reading content...
2025-05-29 12:42:11 - Found 'http://localhost' in file. Setting NEED_API_URL_SET to true.
2025-05-29 12:42:11 - === Finished custom action ===
Can you tell what I am doing wrong?
FOLLOW US
Get the latest news in Application Packaging