Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions assets/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
<?define ExplorerContextSubMenuDialogText = "Open &here"?>
<?define ExplorerContextSubMenuElevatedDialogText = "Open here as &Administrator"?>
<!-- The ProductCode is Product Id and needs to be unique for every PowerShell version to allow SxS install: http://wixtoolset.org/documentation/manual/v3/xsd/wix/product.html -->
<Product
Id="$(var.ProductCode)"
Name="PowerShell $(var.SimpleProductVersion)-$(sys.BUILDARCH)"
Language="1033"
Version="$(var.ProductVersion)"
Manufacturer="Microsoft Corporation"
<Product
Id="$(var.ProductCode)"
Name="PowerShell $(var.SimpleProductVersion)-$(sys.BUILDARCH)"
Language="1033"
Version="$(var.ProductVersion)"
Manufacturer="Microsoft Corporation"
UpgradeCode="$(var.UpgradeCode)">
<!-- Properties About The Package -->
<Package Id="*" Keywords="Installer" Platform="$(sys.BUILDARCH)" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="PowerShell package" Comments="PowerShell for every system" />
Expand All @@ -48,6 +48,8 @@
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Open $(env.ProductName)" />
<!-- Default value of Checkbox of starting PowerShell after installation -->
<Property Id="WixShellExecTarget" Value="[$(var.ProductDirectoryName)]pwsh.exe"/>
<!-- This changes the default setting from "reinstall if the file is a newer version" to "reinstall if the file is a different version" -->
<Property Id="REINSTALLMODE" Value="dmus"/>
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

<SetProperty Id="RegisterManifest"
Expand Down Expand Up @@ -154,7 +156,7 @@
<CreateFolder/>
</Component>
<Component Id="RegistryEntries" Guid="{402e52f7-baf8-489d-af21-f756a6ca3530}">
<!-- create key for easy detection of a particular version of a powershell core package
<!-- create key for easy detection of a particular version of a powershell core package
The upgrade code is used in the key because it will change when we allow SxS -->
<RegistryKey Root="HKLM" Key="Software\Microsoft\PowerShellCore\InstalledVersions\$(var.UpgradeCode)" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value="$(var.ProductSemanticVersion)" Name="SemanticVersion"/>
Expand Down Expand Up @@ -227,9 +229,9 @@
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="$(var.ProductName)">
<Component Id="ApplicationProgramsMenuShortcut" Guid="*">
<Shortcut Id="PowerShell_ProgramsMenuShortcut"
Name="$(var.ProductSimpleVersionWithNameAndOptionalArchitecture)"
Description="$(var.ProductSimpleVersionWithNameAndOptionalArchitecture)"
<Shortcut Id="PowerShell_ProgramsMenuShortcut"
Name="$(var.ProductSimpleVersionWithNameAndOptionalArchitecture)"
Description="$(var.ProductSimpleVersionWithNameAndOptionalArchitecture)"
Target="[$(var.ProductDirectoryName)]pwsh.exe"
Arguments="-WorkingDirectory ~"
Icon = "PowerShellExe.ico" />
Expand Down Expand Up @@ -265,7 +267,7 @@
<Text><![CDATA[<a href="https://github.com/PowerShell/PowerShell/blob/master/ThirdPartyNotices.txt">Please review the ThirdPartyNotices.txt</a>]]></Text>
</Control>
<!-- divider and bottom buttons -->
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" TabSkip="yes"/>
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" TabSkip="yes"/>
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)"/>
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Cancel="yes" Default="yes" Text="!(loc.WixUINext)"/>
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
Expand All @@ -277,7 +279,7 @@

<!-- Customized version of WixUI_InstallDir, which is necessary to add custom dialogs. https://github.com/wixtoolset/wix3/blob/master/src/ext/UIExtension/wixlib/WixUI_InstallDir.wxs -->
<Fragment>
<UI Id="CustomWixUI_InstallDir">
<UI Id="CustomWixUI_InstallDir">
<!--
First-time install dialog sequence:
- WixUI_WelcomeDlg
Expand Down Expand Up @@ -313,8 +315,8 @@
<DialogRef Id="ResumeDlg" />
<DialogRef Id="UserExit" />
<DialogRef Id="ExplorerContextMenuDialog" />


<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>

Expand All @@ -332,7 +334,7 @@
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="ExplorerContextMenuDialog" Order="5">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>

<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ExplorerContextMenuDialog" Order="1">NOT Installed</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>
Expand Down
61 changes: 17 additions & 44 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2646,7 +2646,6 @@ function New-MSIPackage
if ($isPreview)
{
$simpleProductVersion += '-preview'
$FilesWxsPath = New-PreviewFileWxs -FilesWxsPath $FilesWxsPath
}

$ProductVersion = Get-PackageVersionAsMajorMinorBuildRevision -Version $ProductVersion
Expand Down Expand Up @@ -2698,14 +2697,7 @@ function New-MSIPackage

$wixFragmentPath = Join-Path $env:Temp "Fragment.wxs"
$wixObjProductPath = Join-Path $env:Temp "Product.wixobj"
if ($isPreview)
{
$wixObjFragmentPath = Join-Path $env:Temp "files-preview.wixobj"
}
else
{
$wixObjFragmentPath = Join-Path $env:Temp "files.wixobj"
}
$wixObjFragmentPath = Join-Path $env:Temp "files.wixobj"

# cleanup any garbage on the system
Remove-Item -ErrorAction SilentlyContinue $wixFragmentPath -Force
Expand All @@ -2726,8 +2718,24 @@ function New-MSIPackage

Write-Log "verifying no new files have been added or removed..."
Start-NativeExecution -VerboseOutputOnError { & $wixPaths.wixHeatExePath dir $ProductSourcePath -dr $productDirectoryName -cg $productDirectoryName -gg -sfrag -srd -scom -sreg -out $wixFragmentPath -var env.ProductSourcePath -v}

# We are verifying that the generated $wixFragmentPath and $FilesWxsPath are functionally the same
Test-FileWxs -FilesWxsPath $FilesWxsPath -HeatFilesWxsPath $wixFragmentPath

if ($isPreview)
{
# Now that we know that the two are functionally the same,
# We only need to use $FilesWxsPath for release we want to be able to Path
# and two releases shouldn't have the same identifiers,
# so we use the generated one for preview
$FilesWxsPath = $wixFragmentPath

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this break the update one preview to next preview?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is the code we were using before I added the code to allow for patching.


$wixObjFragmentPath = Join-Path $env:Temp "Fragment.wixobj"

# cleanup any garbage on the system
Remove-Item -ErrorAction SilentlyContinue $wixObjFragmentPath -Force
}

Write-Log "running candle..."
Start-NativeExecution -VerboseOutputOnError { & $wixPaths.wixCandleExePath "$ProductWxsPath" "$FilesWxsPath" -out (Join-Path "$env:Temp" "\\") -ext WixUIExtension -ext WixUtilExtension -arch $ProductTargetArchitecture -v}

Expand All @@ -2739,11 +2747,6 @@ 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))
{
Expand All @@ -2765,36 +2768,6 @@ 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
Expand Down