diff --git a/images/windows/scripts/build/Install-PostgreSQL.ps1 b/images/windows/scripts/build/Install-PostgreSQL.ps1 index 2bad88580310..bb5369a653d7 100644 --- a/images/windows/scripts/build/Install-PostgreSQL.ps1 +++ b/images/windows/scripts/build/Install-PostgreSQL.ps1 @@ -58,13 +58,24 @@ if ($null -ne ($toolsetVersion | Select-String -Pattern '\d+\.\d+\.\d+')) { } while (!$response) } +if ((Get-ToolsetContent).postgresql.installVcRedist) { + # Postgres 14 requires the vs 17 redistributable + $vs17RedistUrl = "https://aka.ms/vs/17/release/vc_redist.x64.exe" + Install-Binary ` + -Url $vs17RedistUrl ` + -InstallArgs @("/install", "/quiet", "/norestart") ` + -ExpectedSignature (Get-ToolsetContent).postgresql.vcRedistSignature +} + # Return the previous value of ErrorAction and invoke Install-Binary function $ErrorActionPreference = $errorActionOldValue $installerArgs = @("--install_runtimes 0", "--superpassword root", "--enable_acledit 1", "--unattendedmodeui none", "--mode unattended") + Install-Binary ` -Url $installerUrl ` -InstallArgs $installerArgs ` - -ExpectedSignature (Get-ToolsetContent).postgresql.signature + -ExpectedSignature (Get-ToolsetContent).postgresql.signature ` + -InstallerLogPath "$env:TEMP\**\install-postgresql.log" # Get Path to pg_ctl.exe $pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName diff --git a/images/windows/scripts/helpers/InstallHelpers.ps1 b/images/windows/scripts/helpers/InstallHelpers.ps1 index 67faade1d2a5..a1de82c233dd 100644 --- a/images/windows/scripts/helpers/InstallHelpers.ps1 +++ b/images/windows/scripts/helpers/InstallHelpers.ps1 @@ -30,6 +30,10 @@ function Install-Binary { .PARAMETER ExpectedSHA512Sum The expected SHA512 sum of the binary. If specified, the binary's SHA512 sum is checked before installation. + .PARAMETER InstallerLogPath + The path to the log file which is produced when the installation fails. This can be used for debugging purposes. + This is only displayed when the installation fails. + .EXAMPLE Install-Binary -Url "https://go.microsoft.com/fwlink/p/?linkid=2083338" -Type EXE -InstallArgs ("/features", "+", "/quiet") -ExpectedSignature "A5C7D5B7C838D5F89DDBEDB85B2C566B4CDA881F" #> @@ -46,7 +50,8 @@ function Install-Binary { [String[]] $ExtraInstallArgs, [String[]] $ExpectedSignature, [String] $ExpectedSHA256Sum, - [String] $ExpectedSHA512Sum + [String] $ExpectedSHA512Sum, + [String] $InstallerLogPath ) if ($PSCmdlet.ParameterSetName -eq "LocalPath") { @@ -122,6 +127,15 @@ function Install-Binary { } else { Write-Host "Installation process returned unexpected exit code: $exitCode" Write-Host "Time elapsed: $installCompleteTime seconds" + + if ($InstallerLogPath) { + Write-Host "Searching for logs maching $InstallerLogPath pattern" + Get-ChildItem -Recurse -Path $InstallerLogPath | ForEach-Object { + Write-Output "Found Installer Log: $InstallerLogPath" + Write-Output "File content:" + Get-Content -Path $_.FullName + } + } exit $exitCode } } catch { diff --git a/images/windows/toolsets/toolset-2019.json b/images/windows/toolsets/toolset-2019.json index db9aa6099879..2f45a1678d9c 100644 --- a/images/windows/toolsets/toolset-2019.json +++ b/images/windows/toolsets/toolset-2019.json @@ -472,8 +472,10 @@ "version": "18" }, "postgresql": { - "version": "14.12.1", - "signature": "698BA51AA27CC31282AACA5055E4B9190BC6C0E9" + "signature": "698BA51AA27CC31282AACA5055E4B9190BC6C0E9", + "version": "14", + "vcRedistSignature": "245D262748012A4FE6CE8BA6C951A4C4AFBC3E5D", + "installVcRedist": true }, "kotlin": { "version": "latest" diff --git a/images/windows/toolsets/toolset-2022.json b/images/windows/toolsets/toolset-2022.json index 46c9261bc1e7..d6e1cb5b39d5 100644 --- a/images/windows/toolsets/toolset-2022.json +++ b/images/windows/toolsets/toolset-2022.json @@ -382,8 +382,10 @@ "version": "8.3" }, "postgresql": { - "version": "14.12.1", - "signature": "698BA51AA27CC31282AACA5055E4B9190BC6C0E9" + "signature": "698BA51AA27CC31282AACA5055E4B9190BC6C0E9", + "version": "14", + "vcRedistSignature": "245D262748012A4FE6CE8BA6C951A4C4AFBC3E5D", + "installVcRedist": true }, "kotlin": { "version": "latest"