Enable install of Preview MSI release side-by-side with Stable release (#8513)
When installing (or upgrading) Preview builds the component ids for the files are the same as the installed files from the stable MSI. MSI sees this and assumes the file is already installed so skips installing files that haven't changed (been updated) which results in missing files in the preview install folder and pwsh fails to start. Fix is to dynamically generate new component ids (and compoentrefs) in `files.wxs` using `_Preview` suffix and use that when building a preview package. Tested manually. cc @bergmeister if you can help validate different scenarios. Fix https://github.com/PowerShell/PowerShell/issues/8289
This commit is contained in:
parent
878a46df20
commit
725bfdaf88
|
@ -2530,6 +2530,7 @@ function New-MSIPackage
|
|||
if ($isPreview)
|
||||
{
|
||||
$simpleProductVersion += '-preview'
|
||||
$FilesWxsPath = New-PreviewFileWxs -FilesWxsPath $FilesWxsPath
|
||||
}
|
||||
|
||||
$ProductVersion = Get-PackageVersionAsMajorMinorBuildRevision -Version $ProductVersion
|
||||
|
@ -2581,7 +2582,14 @@ function New-MSIPackage
|
|||
|
||||
$wixFragmentPath = Join-Path $env:Temp "Fragment.wxs"
|
||||
$wixObjProductPath = Join-Path $env:Temp "Product.wixobj"
|
||||
$wixObjFragmentPath = Join-Path $env:Temp "files.wixobj"
|
||||
if ($isPreview)
|
||||
{
|
||||
$wixObjFragmentPath = Join-Path $env:Temp "files-preview.wixobj"
|
||||
}
|
||||
else
|
||||
{
|
||||
$wixObjFragmentPath = Join-Path $env:Temp "files.wixobj"
|
||||
}
|
||||
|
||||
# cleanup any garbage on the system
|
||||
Remove-Item -ErrorAction SilentlyContinue $wixFragmentPath -Force
|
||||
|
@ -2615,6 +2623,11 @@ function New-MSIPackage
|
|||
Remove-Item -ErrorAction SilentlyContinue $wixFragmentPath -Force
|
||||
Remove-Item -ErrorAction SilentlyContinue $wixObjProductPath -Force
|
||||
Remove-Item -ErrorAction SilentlyContinue $wixObjFragmentPath -Force
|
||||
if ($isPreview)
|
||||
{
|
||||
# remove the temporary generated files.wxs for preview builds
|
||||
Remove-Item -ErrorAction SilentlyContinue $FilesWxsPath -Force
|
||||
}
|
||||
|
||||
if ((Test-Path $msiLocationPath) -and (Test-Path $msiPdbLocationPath))
|
||||
{
|
||||
|
@ -2636,6 +2649,36 @@ function New-MSIPackage
|
|||
}
|
||||
}
|
||||
|
||||
# generate a files.wxs for preview builds
|
||||
# so that the component ids are different than the stable builds
|
||||
# the file is created in the temp folder
|
||||
function New-PreviewFileWxs
|
||||
{
|
||||
param
|
||||
(
|
||||
# File describing the MSI file components from the asset folder
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateScript( {Test-Path $_})]
|
||||
[string] $FilesWxsPath = "$RepoRoot\assets\Files.wxs"
|
||||
)
|
||||
|
||||
Write-Verbose "Generating new component Ids for Files-Preview.wxs" -Verbose
|
||||
[xml] $filesAssetXml = Get-Content -Raw -Path $FilesWxsPath
|
||||
foreach($component in $filesAssetXml.GetElementsByTagName('Component'))
|
||||
{
|
||||
$component.Id = $component.Id + "_Preview"
|
||||
}
|
||||
|
||||
foreach($componentRef in $filesAssetXml.GetElementsByTagName('ComponentRef'))
|
||||
{
|
||||
$componentRef.Id = $componentRef.Id + "_Preview"
|
||||
}
|
||||
|
||||
$previewFilesWxsPath = Join-Path ([System.IO.Path]::GetTempPath()) "Files-Preview.wxs"
|
||||
$filesAssetXml.Save($previewFilesWxsPath)
|
||||
$previewFilesWxsPath
|
||||
}
|
||||
|
||||
# verify no files have been added or removed
|
||||
# if so, write an error with details
|
||||
function Test-FileWxs
|
||||
|
|
Loading…
Reference in a new issue