From 55aa8d4b7877a986aec90a4e0407eef86b530e42 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Fri, 28 Apr 2023 11:31:59 -0700 Subject: [PATCH 1/8] Add ProductCode in registry for MSI install --- assets/wix/Product.wxs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/wix/Product.wxs b/assets/wix/Product.wxs index 976a12d1425..30318916544 100644 --- a/assets/wix/Product.wxs +++ b/assets/wix/Product.wxs @@ -205,7 +205,9 @@ + + From a86c6df37831efc28d6eaee87ac5e69091a0c5e1 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Mon, 1 May 2023 14:38:31 -0700 Subject: [PATCH 2/8] Add test for validating ProductCode regkey is created --- test/packaging/windows/msi.tests.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/packaging/windows/msi.tests.ps1 b/test/packaging/windows/msi.tests.ps1 index 71254d287bc..7878732b11b 100644 --- a/test/packaging/windows/msi.tests.ps1 +++ b/test/packaging/windows/msi.tests.ps1 @@ -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" @@ -196,6 +201,12 @@ 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)) { + $regKeyPath | Should -Exist + $productCode = Get-ItemPropertyValue -Path $regKeyPath -Name 'ProductCode' + $productCode | Should -Not -BeNullOrEmpty + } + It "MSI should uninstall without error" -Skip:(!(Test-Elevated)) { { Invoke-MsiExec -Uninstall -MsiPath $msiX64Path From 2a9f12dc5692b5480de98ae36d3c2c2ba50f5a51 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Mon, 1 May 2023 14:44:22 -0700 Subject: [PATCH 3/8] Add test better validation --- test/packaging/windows/msi.tests.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/packaging/windows/msi.tests.ps1 b/test/packaging/windows/msi.tests.ps1 index 7878732b11b..248f7fa6590 100644 --- a/test/packaging/windows/msi.tests.ps1 +++ b/test/packaging/windows/msi.tests.ps1 @@ -205,6 +205,9 @@ Describe -Name "Windows MSI" -Fixture { $regKeyPath | Should -Exist $productCode = Get-ItemPropertyValue -Path $regKeyPath -Name '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)) { From da98255a19f789006379280e54a6603d78197412 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 9 May 2023 15:46:25 -0700 Subject: [PATCH 4/8] Fix test for x86 packages --- build.psm1 | 2 +- test/packaging/windows/msi.tests.ps1 | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build.psm1 b/build.psm1 index 3d0be1a846b..b850e6b4e79 100644 --- a/build.psm1 +++ b/build.psm1 @@ -951,7 +951,7 @@ function New-PSOptions { } } - $PowerShellDir = if ($Runtime -like 'win*' -or ($Runtime -like 'fxdependent*' -and $environment.IsWindows)) { + $PowerShellDir = if (($Runtime -like 'win*' -or ($Runtime -like 'fxdependent*' -and $environment.IsWindows)) -and (-not $Runtime -like 'fxdependent*linux*')) { "powershell-win-core" } else { "powershell-unix" diff --git a/test/packaging/windows/msi.tests.ps1 b/test/packaging/windows/msi.tests.ps1 index 248f7fa6590..8d5051b5f13 100644 --- a/test/packaging/windows/msi.tests.ps1 +++ b/test/packaging/windows/msi.tests.ps1 @@ -202,8 +202,20 @@ Describe -Name "Windows MSI" -Fixture { } It 'MSI should add ProductCode in registry' -Skip:(!(Test-Elevated)) { - $regKeyPath | Should -Exist - $productCode = Get-ItemPropertyValue -Path $regKeyPath -Name 'ProductCode' + + $productCode = if ($msiUpgradeCode -eq '39243d76-adaf-42b1-94fb-16ecf83237c8' -or + $msi -eq '31ab5147-9a97-4452-8443-d9709f0516e1') { + # x64 + $regKeyPath | Should -Exist + $productCode = Get-ItemPropertyValue -Path $regKeyPath -Name 'ProductCode' + } elseif ($msiUpgradeCode -eq '39243d76-adaf-42b1-94fb-16ecf83237c8' -or + $msi -eq '31ab5147-9a97-4452-8443-d9709f0516e1') { + # 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" From a4e376c801aa92dba267320bda79e08a066c4abd Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 9 May 2023 16:26:48 -0700 Subject: [PATCH 5/8] Fixed the upgrade codes in test --- test/packaging/windows/msi.tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/packaging/windows/msi.tests.ps1 b/test/packaging/windows/msi.tests.ps1 index 8d5051b5f13..162dbfcd850 100644 --- a/test/packaging/windows/msi.tests.ps1 +++ b/test/packaging/windows/msi.tests.ps1 @@ -208,8 +208,8 @@ Describe -Name "Windows MSI" -Fixture { # x64 $regKeyPath | Should -Exist $productCode = Get-ItemPropertyValue -Path $regKeyPath -Name 'ProductCode' - } elseif ($msiUpgradeCode -eq '39243d76-adaf-42b1-94fb-16ecf83237c8' -or - $msi -eq '31ab5147-9a97-4452-8443-d9709f0516e1') { + } elseif ($msiUpgradeCode -eq '86abcfbd-1ccc-4a88-b8b2-0facfde29094' -or + $msi -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") From 4a3f2e863de6a78474d92ac954eadf4c0f4e3517 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 9 May 2023 17:25:26 -0700 Subject: [PATCH 6/8] Fix typo --- test/packaging/windows/msi.tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/packaging/windows/msi.tests.ps1 b/test/packaging/windows/msi.tests.ps1 index 162dbfcd850..9b749ffaa3b 100644 --- a/test/packaging/windows/msi.tests.ps1 +++ b/test/packaging/windows/msi.tests.ps1 @@ -204,12 +204,12 @@ Describe -Name "Windows MSI" -Fixture { It 'MSI should add ProductCode in registry' -Skip:(!(Test-Elevated)) { $productCode = if ($msiUpgradeCode -eq '39243d76-adaf-42b1-94fb-16ecf83237c8' -or - $msi -eq '31ab5147-9a97-4452-8443-d9709f0516e1') { + $msiUpgradeCode -eq '31ab5147-9a97-4452-8443-d9709f0516e1') { # x64 $regKeyPath | Should -Exist $productCode = Get-ItemPropertyValue -Path $regKeyPath -Name 'ProductCode' } elseif ($msiUpgradeCode -eq '86abcfbd-1ccc-4a88-b8b2-0facfde29094' -or - $msi -eq '1d00683b-0f84-4db8-a64f-2f98ad42fe06') { + $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") From a336c09423a43598e8f50c5c00d851f95c5fccda Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 9 May 2023 19:37:00 -0700 Subject: [PATCH 7/8] return product code value --- test/packaging/windows/msi.tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/packaging/windows/msi.tests.ps1 b/test/packaging/windows/msi.tests.ps1 index 9b749ffaa3b..93a56821003 100644 --- a/test/packaging/windows/msi.tests.ps1 +++ b/test/packaging/windows/msi.tests.ps1 @@ -207,7 +207,7 @@ Describe -Name "Windows MSI" -Fixture { $msiUpgradeCode -eq '31ab5147-9a97-4452-8443-d9709f0516e1') { # x64 $regKeyPath | Should -Exist - $productCode = Get-ItemPropertyValue -Path $regKeyPath -Name 'ProductCode' + 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 From d71fd4ca82f26af76ed2536e81b08c0a00c0b06a Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 9 May 2023 21:43:34 -0700 Subject: [PATCH 8/8] Revert inadvertant change --- build.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index b850e6b4e79..3d0be1a846b 100644 --- a/build.psm1 +++ b/build.psm1 @@ -951,7 +951,7 @@ function New-PSOptions { } } - $PowerShellDir = if (($Runtime -like 'win*' -or ($Runtime -like 'fxdependent*' -and $environment.IsWindows)) -and (-not $Runtime -like 'fxdependent*linux*')) { + $PowerShellDir = if ($Runtime -like 'win*' -or ($Runtime -like 'fxdependent*' -and $environment.IsWindows)) { "powershell-win-core" } else { "powershell-unix"