Specify when you'd like to build drivers before building installers.
.PARAMETER ExcludeRuntime
Specify when you'd like to exclude a msvc runtime dll from the installer.
+.PARAMETER RedistUCRT
+ Specify when you'd like to redistribute Visual C++ 2015(or later) Redistributable.
.PARAMETER BuildConfigPath
Specify the configuration xml file name if you want to use
the configuration file other than standard one.
[string]$cpu="both",
[switch]$AlongWithDrivers,
[switch]$ExcludeRuntime,
+[switch]$RedistUCRT,
[string]$BuildConfigPath
)
-function findRuntime($runtime_version, $pgmvc)
+[int]$ucrt_version=14
+[String]$str_msvcr="msvcr"
+[String]$str_vcrun="vcruntime"
+[String]$str_msvcp="msvcp"
+[String]$msrun_ptn="msvcr|vcruntime"
+
+function msvcrun([int]$runtime_version)
+{
+ [String]$str = if ($runtime_version -lt $ucrt_version) {$str_msvcr} else {$str_vcrun}
+ return $str
+}
+
+function findRuntime([int]$runtime_version, [String]$pgmvc)
{
# where's the dll?
- $rt_dllname="msvcr${runtime_version}0.dll"
+ [String]$rt_dllname = (msvcrun $runtime_version) + "${runtime_version}0.dll"
if ("$pgmvc" -ne "") {
$dllspecified = "${pgmvc}\${rt_dllname}"
if (Test-Path -Path $dllspecified) {
- $dllspecified
- return ""
+ return $dllspecified, ""
}
}
$dllinredist = "${LIBPQBINDIR}\${rt_dllname}"
if (Test-Path -Path $dllinredist) {
- $dllinredist
- return ""
+ return $dllinredist, ""
}
if ($env:PROCESSOR_ARCHITECTURE -eq "x86") {
$pgmvc = "$env:ProgramFiles"
}
$dllinredist = "$pgmvc\Microsoft Visual Studio ${runtime_version}.0\VC\redist\${CPUTYPE}\Microsoft.VC${runtime_version}0.CRT\${rt_dllname}"
if (Test-Path -Path $dllinredist) {
- $dllinredist
- return ""
+ return $dllinredist, ""
} else {
$messageSpec = "Please specify Configuration.$CPUTYPE.runtime_folder element of the configuration file where msvc runtime dll $rt_dllname can be found"
if ($CPUTYPE -eq "x86") {
throw "${messageSpec}`nneither $dllinredist nor $dllinsystem exists unfortunately"
}
}
- ""
- return $rt_dllname
+ return "", $rt_dllname
}
function getVersion($connInfo)
if (-not $ExcludeRuntime) {
$toolset = $configInfo.Configuration.BuildResult.PlatformToolset
if ($toolset -match "^v(\d+)0") {
- $runtime_version0 = $matches[1]
+ $runtime_version0 = [int]$matches[1]
} else {
- $runtime_version0 = "10"
+ $runtime_version0 = 10
}
# where's the msvc runtime dll psqlodbc links?
- if ([int] $runtime_version0 -lt 14) {
+ if ($runtime_version0 -ge $ucrt_version -and $RedistUCRT) {
+ $script:wRedist=$true
+ } else {
$dlls=findRuntime $runtime_version0 $pgmvc
$PODBCMSVCDLL=$dlls[0]
- $PODBCMSVPDLL=$PODBCMSVCDLL.Replace("msvcr", "msvcp")
$PODBCMSVCSYS=$dlls[1]
- $PODBCMSVPSYS=$PODBCMSVCSYS.Replace("msvcr", "msvcp")
+ $PODBCMSVPDLL=$PODBCMSVCDLL.Replace((msvcrun $runtime_version0), $str_msvcp)
+ $PODBCMSVPSYS=$PODBCMSVCSYS.Replace((msvcrun $runtime_version0), $str_msvcp)
}
# where's the runtime dll libpq links?
- $msvclist=& ${dumpbinexe} /imports $LIBPQBINDIR\libpq.dll | select-string -pattern "^\s*msvcr(\d+)0\.dll" | % {$_.matches[0].Groups[1].Value}
+ $msvclist=& ${dumpbinexe} /imports $LIBPQBINDIR\libpq.dll | select-string -pattern "^\s*($msrun_ptn)(\d+)0\.dll" | % {$_.matches[0].Groups[2].Value}
if ($msvclist -ne $Null -and $msvclist.length -gt 0) {
if ($msvclist.GetType().Name -eq "String") {
- $runtime_version1=$msvclist
+ $runtime_version1=[int]$msvclist
} else {
- $runtime_version1=$msvclist[0]
+ $runtime_version1=[int]$msvclist[0]
}
- if ($runtime_version1 -ne $runtime_version0) {
+ if ($runtime_version1 -ge $ucrt_version -and $RedistUCRT) {
+ $script:wRedist=$true
+ } elseif ($runtime_version1 -ne $runtime_version0) {
$dlls=findRuntime $runtime_version1 $pgmvc
$LIBPQMSVCDLL=$dlls[0]
$LIBPQMSVCSYS=$dlls[1]
- Write-Host "LIBPQ requires msvcr${runtime_version1}0.dll"
+ Write-Host "LIBPQ requires $LIBPQMSVCDLL$LIBPQMSYCSYS"
}
+ } else {
+ $script:wRedist=$true
}
}
$maxmem=10
$libpqmem=Get-RelatedDlls "libpq.dll" $LIBPQBINDIR
for ($i=0; $i -lt $libpqmem.length; ) {
- if ($libpqmem[$i] -match "^msvcr\d+0.dll") {
+ if ($libpqmem[$i] -match "^($msrun_ptn)\d+0.dll") {
$libpqmem[$i]=$Null
} else {
$i++
try {
$dumpbinexe = Find-Dumpbin
+ $wRedist=$false
$VERSION = getVersion $configInfo
if ($cpu -eq "both") {
buildInstaller "x86"
buildInstaller "x64"
+ $VERSION = $configInfo.Configuration.version
+ write-host "wRedist=$wRedist"
try {
pushd "$scriptPath"
- psqlodbc-setup\buildBootstrapper.ps1 -version $VERSION
+ psqlodbc-setup\buildBootstrapper.ps1 -version $VERSION -withRedist:$wRedist
if ($LASTEXITCODE -ne 0) {
throw "Failed to build bootstrapper"
}
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!-- ?define vcredist_x86 = http://download.microsoft.com/download/d/d/9/dd9a82d0-52ef-40db-8dab-795376989c03/vcredist_x86.exe ?>\r
-<?define vcredist_x64 = http://download.microsoft.com/download/d/d/9/dd9a82d0-52ef-40db-8dab-795376989c03/vcredist_x64.exe ? -->\r
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"\r
- xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">\r
- <Fragment>\r
- <!-- TODO: Put your code here. -->\r
- <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" Value="Installed" Variable="vc100_redist_x86" />\r
- <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x64" Value="Installed" Variable="vc100_redist_x64" Win64="yes"/>\r
- <PackageGroup Id="vcredist">\r
- <ExePackage Id="vc100_redist_x86"\r
- Cache="no"\r
- Compressed="yes"\r
- PerMachine="yes"\r
- Permanent="yes"\r
- Vital="yes"\r
- Name="Redist\vc100_redist_x86.exe"\r
- SourceFile="vc100_redist_x86.exe"\r
- InstallCommand="/q"\r
- DetectCondition="vc100_redist_x86 AND (vc100_redist_x86 >= 1)">\r
- <ExitCode Value ="3010" Behavior="forceReboot" />\r
- </ExePackage>\r
- <ExePackage Id="vc100_redist_x64"\r
- Cache="no"\r
- Compressed="yes"\r
- PerMachine="yes"\r
- Permanent="yes"\r
- Vital="yes"\r
- Name="Redist\vc100_redist_x64.exe"\r
- SourceFile="vc100_redist_x64.exe"\r
- InstallCommand="/q"\r
- InstallCondition="VersionNT64"\r
- DetectCondition="vc100_redist_x64 AND (vc100_redist_x64 >= 1)">\r
- <ExitCode Value ="3010" Behavior="forceReboot" />\r
- </ExePackage>\r
- </PackageGroup>\r
- </Fragment>\r
-</Wix>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<?ifndef VCVER?>
+<?define VCVER = 14?>
+<?endif?>
+<!-- ?define vcredist_x86 = http://download.microsoft.com/download/d/d/9/dd9a82d0-52ef-40db-8dab-795376989c03/vcredist_x86.exe ?>
+<?define vcredist_x64 = http://download.microsoft.com/download/d/d/9/dd9a82d0-52ef-40db-8dab-795376989c03/vcredist_x64.exe ? -->
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
+ xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
+ <Fragment>
+ <!-- TODO: Put your code here. -->
+ <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\$(var.VCVER).0\VC\VCRedist\x86" Value="Installed" Variable="vc$(var.VCVER)0_redist_x86" />
+ <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\$(var.VCVER).0\VC\VCRedist\x64" Value="Installed" Variable="vc$(var.VCVER)0_redist_x64" Win64="yes"/>
+ <PackageGroup Id="vcredist">
+ <ExePackage Id="vc$(var.VCVER)0_redist_x86"
+ Cache="no"
+ Compressed="yes"
+ PerMachine="yes"
+ Permanent="yes"
+ Vital="yes"
+ Name="vc$(var.VCVER)0_redist_x86.exe"
+ SourceFile="Redist\vc$(var.VCVER)0_redist_x86.exe"
+ InstallCommand="/q"
+ DetectCondition="vc$(var.VCVER)0_redist_x86 AND (vc$(var.VCVER)0_redist_x86 >= 1)">
+ <ExitCode Value ="3010" Behavior="forceReboot" />
+ </ExePackage>
+ <ExePackage Id="vc$(var.VCVER)0_redist_x64"
+ Cache="no"
+ Compressed="yes"
+ PerMachine="yes"
+ Permanent="yes"
+ Vital="yes"
+ Name="vc$(var.VCVER)0_redist_x64.exe"
+ SourceFile="Redist\vc$(var.VCVER)0_redist_x64.exe"
+ InstallCommand="/q"
+ InstallCondition="VersionNT64"
+ DetectCondition="vc$(var.VCVER)0_redist_x64 AND (vc$(var.VCVER)0_redist_x64 >= 1)">
+ <ExitCode Value ="3010" Behavior="forceReboot" />
+ </ExePackage>
+ </PackageGroup>
+ </Fragment>
+</Wix>