fix MSI creation errors, and capture wixpdb for later patch creation (#6221)
- add `wixpdb` output when creating `MSI` package - capture `wixpdb` in official build - clean up anything left behind from previous MSI builds before starting MSI build to prevent using dirty files. - make sure MSI creation fails if there is an error - ignore `.wixpdb` files in git - Add functionality to `Start-NativeExecution` to - only display output if there is an error - log caller information - WXS validation error fixes - Remove unused `ExitDialog` to fix ICE82 - Add KeyPath to `SetPath` to fix ICE18 - Use `HKMU` which translates to `HKLM` to runtime to fix various validation errors about creating the shortcut - Suppress Validation errors - suppress ICE61, which is about same version upgrades being allowed - suppress ICE57, caused by the shortcut not being installed per user
This commit is contained in:
parent
a53547ce78
commit
49ec403899
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -35,6 +35,7 @@ dotnet-uninstall-debian-packages.sh
|
|||
# Ignore binaries and symbols
|
||||
*.pdb
|
||||
*.dll
|
||||
*.wixpdb
|
||||
|
||||
# Ignore packages
|
||||
*.deb
|
||||
|
|
|
@ -157,7 +157,7 @@
|
|||
</RegistryKey>
|
||||
</Component>
|
||||
<!-- add ourselves to %PATH% so pwsh.exe can be started from Windows PowerShell or cmd.exe -->
|
||||
<Component Id="SetPath" Guid="{9dbb7763-7baf-48e7-b025-3bdedcb0632f}">
|
||||
<Component Id="SetPath" Guid="{9dbb7763-7baf-48e7-b025-3bdedcb0632f}" KeyPath="yes">
|
||||
<Environment Id="PATH" Action="set" Name="PATH" Part="last" Permanent="no" System="yes" Value="[$(var.ProductVersionWithName)]"/>
|
||||
</Component>
|
||||
<!-- Explorer context menu with 2 submenus to open PowerShell normally or as an Administator.
|
||||
|
@ -211,10 +211,15 @@
|
|||
<Directory Id="ProgramMenuFolder">
|
||||
<Directory Id="ApplicationProgramsFolder" Name="$(var.ProductName)">
|
||||
<Component Id="ApplicationProgramsMenuShortcut" Guid="{A77507A7-F970-4618-AC30-20AFE36EE2EB}">
|
||||
<Shortcut Id="PowerShell_ProgramsMenuShortcut" Name="$(var.ProductSemanticVersionWithNameAndOptionalArchitecture)" Description="$(var.ProductSemanticVersionWithNameAndOptionalArchitecture)" Target="[$(var.ProductVersionWithName)]pwsh.exe" WorkingDirectory="$(var.ProductVersionWithName)"
|
||||
Icon = "PowerShellExe.ico" />
|
||||
<Shortcut Id="PowerShell_ProgramsMenuShortcut"
|
||||
Name="$(var.ProductSemanticVersionWithNameAndOptionalArchitecture)"
|
||||
Description="$(var.ProductSemanticVersionWithNameAndOptionalArchitecture)"
|
||||
Target="[$(var.ProductVersionWithName)]pwsh.exe"
|
||||
WorkingDirectory="$(var.ProductVersionWithName)"
|
||||
Icon = "PowerShellExe.ico" />
|
||||
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
|
||||
<RegistryValue Root="HKLM" Key="Software\Microsoft\$(var.ProductSemanticVersionWithNameAndOptionalArchitecture)\ProgramsMenuShortcut" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
|
||||
<!-- HKMU is HKLM when installing perMachine and HKCU when installing perUser-->
|
||||
<RegistryValue Root="HKMU" Key="Software\Microsoft\$(var.ProductSemanticVersionWithNameAndOptionalArchitecture)\ProgramsMenuShortcut" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
|
||||
</Component>
|
||||
</Directory>
|
||||
</Directory>
|
||||
|
@ -289,8 +294,6 @@
|
|||
<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
|
||||
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
|
||||
|
||||
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
|
||||
|
||||
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed</Publish>
|
||||
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
|
||||
|
||||
|
|
39
build.psm1
39
build.psm1
|
@ -2027,15 +2027,50 @@ function script:precheck([string]$command, [string]$missedMessage) {
|
|||
|
||||
# this function wraps native command Execution
|
||||
# for more information, read https://mnaoumov.wordpress.com/2015/01/11/execution-of-external-commands-in-powershell-done-right/
|
||||
function script:Start-NativeExecution([scriptblock]$sb, [switch]$IgnoreExitcode)
|
||||
function script:Start-NativeExecution
|
||||
{
|
||||
param(
|
||||
[scriptblock]$sb,
|
||||
[switch]$IgnoreExitcode,
|
||||
[switch]$VerboseOutputOnError
|
||||
)
|
||||
$backupEAP = $script:ErrorActionPreference
|
||||
$script:ErrorActionPreference = "Continue"
|
||||
try {
|
||||
& $sb
|
||||
if($VerboseOutputOnError.IsPresent)
|
||||
{
|
||||
$output = & $sb
|
||||
}
|
||||
else
|
||||
{
|
||||
& $sb
|
||||
}
|
||||
|
||||
# note, if $sb doesn't have a native invocation, $LASTEXITCODE will
|
||||
# point to the obsolete value
|
||||
if ($LASTEXITCODE -ne 0 -and -not $IgnoreExitcode) {
|
||||
if($VerboseOutputOnError.IsPresent -and $output)
|
||||
{
|
||||
$output | Out-String | Write-Verbose -Verbose
|
||||
}
|
||||
|
||||
# Get caller location for easier debugging
|
||||
$caller = Get-PSCallStack -ErrorAction SilentlyContinue
|
||||
if($caller)
|
||||
{
|
||||
$callerLocationParts = $caller[1].Location -split ":\s*line\s*"
|
||||
$callerFile = $callerLocationParts[0]
|
||||
$callerLine = $callerLocationParts[1]
|
||||
|
||||
$errorMessage = "Execution of {$sb} by ${callerFile}: line $callerLine failed with exit code $LASTEXITCODE"
|
||||
|
||||
if ($null -ne $env:CI)
|
||||
{
|
||||
Add-AppveyorCompilationMessage $errorMessage -Category Error -FileName $callerFile -Line $callerLine
|
||||
}
|
||||
|
||||
throw $errorMessage
|
||||
}
|
||||
throw "Execution of {$sb} failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
} finally {
|
||||
|
|
|
@ -2120,36 +2120,49 @@ function New-MSIPackage
|
|||
$wixObjProductPath = Join-Path $env:Temp "Product.wixobj"
|
||||
$wixObjFragmentPath = Join-Path $env:Temp "Fragment.wixobj"
|
||||
|
||||
# cleanup any garbage on the system
|
||||
Remove-Item -ErrorAction SilentlyContinue $wixFragmentPath -Force
|
||||
Remove-Item -ErrorAction SilentlyContinue $wixObjProductPath -Force
|
||||
Remove-Item -ErrorAction SilentlyContinue $wixObjFragmentPath -Force
|
||||
|
||||
$packageName = $productSemanticVersionWithName
|
||||
if ($ProductNameSuffix) {
|
||||
$packageName += "-$ProductNameSuffix"
|
||||
}
|
||||
$msiLocationPath = Join-Path $pwd "$packageName.msi"
|
||||
$msiPdbLocationPath = Join-Path $pwd "$packageName.wixpdb"
|
||||
|
||||
if(!$Force.IsPresent -and (Test-Path -Path $msiLocationPath))
|
||||
{
|
||||
Write-Error -Message "Package already exists, use -Force to overwrite, path: $msiLocationPath" -ErrorAction Stop
|
||||
}
|
||||
|
||||
$WiXHeatLog = & $wixHeatExePath dir $ProductSourcePath -dr $productVersionWithName -cg $productVersionWithName -gg -sfrag -srd -scom -sreg -out $wixFragmentPath -var env.ProductSourcePath -v
|
||||
$WiXCandleLog = & $wixCandleExePath "$ProductWxsPath" "$wixFragmentPath" -out (Join-Path "$env:Temp" "\\") -ext WixUIExtension -ext WixUtilExtension -arch $ProductTargetArchitecture -v
|
||||
$WiXLightLog = & $wixLightExePath -out $msiLocationPath $wixObjProductPath $wixObjFragmentPath -ext WixUIExtension -ext WixUtilExtension -dWixUILicenseRtf="$LicenseFilePath" -v
|
||||
log "running heat..."
|
||||
Start-NativeExecution -VerboseOutputOnError { & $wixHeatExePath dir $ProductSourcePath -dr $productVersionWithName -cg $productVersionWithName -gg -sfrag -srd -scom -sreg -out $wixFragmentPath -var env.ProductSourcePath -v}
|
||||
|
||||
log "running candle..."
|
||||
Start-NativeExecution -VerboseOutputOnError { & $wixCandleExePath "$ProductWxsPath" "$wixFragmentPath" -out (Join-Path "$env:Temp" "\\") -ext WixUIExtension -ext WixUtilExtension -arch $ProductTargetArchitecture -v}
|
||||
|
||||
log "running light..."
|
||||
# suppress ICE61, because we allow same version upgrades
|
||||
# suppress ICE57, this suppresses an error caused by our shortcut not being installed per user
|
||||
Start-NativeExecution -VerboseOutputOnError {& $wixLightExePath -sice:ICE61 -sice:ICE57 -out $msiLocationPath -pdbout $msiPdbLocationPath $wixObjProductPath $wixObjFragmentPath -ext WixUIExtension -ext WixUtilExtension -dWixUILicenseRtf="$LicenseFilePath"}
|
||||
|
||||
Remove-Item -ErrorAction SilentlyContinue *.wixpdb -Force
|
||||
Remove-Item -ErrorAction SilentlyContinue $wixFragmentPath -Force
|
||||
Remove-Item -ErrorAction SilentlyContinue $wixObjProductPath -Force
|
||||
Remove-Item -ErrorAction SilentlyContinue $wixObjFragmentPath -Force
|
||||
|
||||
if (Test-Path $msiLocationPath)
|
||||
if ((Test-Path $msiLocationPath) -and (Test-Path $msiPdbLocationPath))
|
||||
{
|
||||
Write-Verbose "You can find the WixPdb @ $msiPdbLocationPath" -Verbose
|
||||
Write-Verbose "You can find the MSI @ $msiLocationPath" -Verbose
|
||||
$msiLocationPath
|
||||
[pscustomobject]@{
|
||||
msi=$msiLocationPath
|
||||
wixpdb=$msiPdbLocationPath
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$WiXHeatLog | Out-String | Write-Verbose -Verbose
|
||||
$WiXCandleLog | Out-String | Write-Verbose -Verbose
|
||||
$WiXLightLog | Out-String | Write-Verbose -Verbose
|
||||
$errorMessage = "Failed to create $msiLocationPath"
|
||||
if ($null -ne $env:CI)
|
||||
{
|
||||
|
|
|
@ -105,7 +105,7 @@ try{
|
|||
|
||||
Write-Verbose "Exporting packages ..." -verbose
|
||||
|
||||
Get-ChildItem $location\*.msi,$location\*.zip | ForEach-Object {
|
||||
Get-ChildItem $location\*.msi,$location\*.zip,$location\*.wixpdb | ForEach-Object {
|
||||
$file = $_.FullName
|
||||
Write-Verbose "Copying $file to $destination" -verbose
|
||||
Copy-Item -Path $file -Destination "$destination\" -Force
|
||||
|
|
Loading…
Reference in a new issue