Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/v7.3.6]Add ProductCode in registry for MSI install #19951

Merged
merged 1 commit into from
Jul 12, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions assets/wix/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@
<RegistryKey Root="HKLM" Key="Software\Microsoft\PowerShellCore\InstalledVersions\$(var.UpgradeCode)" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value="$(var.ProductSemanticVersion)" Name="SemanticVersion" KeyPath="yes"/>
<RegistryValue Type="string" Value="[VersionFolder]" Name="InstallLocation" />
<RegistryValue Type="string" Value="[ProductCode]" Name="ProductCode" />
</RegistryKey>

</Component>
<Component Id="SharedRegistryEntries">
<!-- register ourselves in application registry so can be started using just Win+R `pwsh.exe` -->
Expand Down
26 changes: 26 additions & 0 deletions test/packaging/windows/msi.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,27 +144,32 @@ Describe -Name "Windows MSI" -Fixture {
Write-Verbose "cr-$channel-$runtime" -Verbose
$pwshPath = Join-Path $env:ProgramFiles -ChildPath "PowerShell"
$pwshx86Path = Join-Path ${env:ProgramFiles(x86)} -ChildPath "PowerShell"
$regKeyPath = "HKLM:\SOFTWARE\Microsoft\PowerShellCore\InstalledVersions"

switch ("$channel-$runtime") {
"preview-win7-x64" {
$versionPath = Join-Path -Path $pwshPath -ChildPath '7-preview'
$revisionRange = 0, 99
$msiUpgradeCode = '39243d76-adaf-42b1-94fb-16ecf83237c8'
$regKeyPath = Join-Path $regKeyPath -ChildPath $msiUpgradeCode
}
"stable-win7-x64" {
$versionPath = Join-Path -Path $pwshPath -ChildPath '7'
$revisionRange = 500, 500
$msiUpgradeCode = '31ab5147-9a97-4452-8443-d9709f0516e1'
$regKeyPath = Join-Path $regKeyPath -ChildPath $msiUpgradeCode
}
"preview-win7-x86" {
$versionPath = Join-Path -Path $pwshx86Path -ChildPath '7-preview'
$revisionRange = 0, 99
$msiUpgradeCode = '86abcfbd-1ccc-4a88-b8b2-0facfde29094'
$regKeyPath = Join-Path $regKeyPath -ChildPath $msiUpgradeCode
}
"stable-win7-x86" {
$versionPath = Join-Path -Path $pwshx86Path -ChildPath '7'
$revisionRange = 500, 500
$msiUpgradeCode = '1d00683b-0f84-4db8-a64f-2f98ad42fe06'
$regKeyPath = Join-Path $regKeyPath -ChildPath $msiUpgradeCode
}
default {
throw "'$_' not a valid channel runtime combination"
Expand Down Expand Up @@ -196,6 +201,27 @@ Describe -Name "Windows MSI" -Fixture {
$version.Revision | Should -BeLessOrEqual $revisionRange[1] -Because "$channel revision should between $($revisionRange[0]) and $($revisionRange[1])"
}

It 'MSI should add ProductCode in registry' -Skip:(!(Test-Elevated)) {

$productCode = if ($msiUpgradeCode -eq '39243d76-adaf-42b1-94fb-16ecf83237c8' -or
$msiUpgradeCode -eq '31ab5147-9a97-4452-8443-d9709f0516e1') {
# x64
$regKeyPath | Should -Exist
Get-ItemPropertyValue -Path $regKeyPath -Name 'ProductCode'
} elseif ($msiUpgradeCode -eq '86abcfbd-1ccc-4a88-b8b2-0facfde29094' -or
$msiUpgradeCode -eq '1d00683b-0f84-4db8-a64f-2f98ad42fe06') {
# x86 - need to open the 32bit reghive
$wow32RegKey = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry32)
$subKey = $wow32RegKey.OpenSubKey("Software\Microsoft\PowerShellCore\InstalledVersions\$msiUpgradeCode")
$subKey.GetValue("ProductCode")
}

$productCode | Should -Not -BeNullOrEmpty
$productCodeGuid = [Guid]$productCode
$productCodeGuid | Should -BeOfType "Guid"
$productCodeGuid.Guid | Should -Not -Be $msiUpgradeCode
}

It "MSI should uninstall without error" -Skip:(!(Test-Elevated)) {
{
Invoke-MsiExec -Uninstall -MsiPath $msiX64Path
Expand Down