-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add exe wrapper for Microsoft Update scenarios #14737
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
67100df
try to create bundle
TravisEz13 ee002d0
remove license
TravisEz13 cd62306
add license URL
TravisEz13 e6ab551
add license rtf
TravisEz13 a4c7985
make everything a variable
TravisEz13 31f4c64
make a windows version
TravisEz13 ed73610
fix typo
TravisEz13 dccba8f
don't add 0 if it exists
TravisEz13 ede498d
Revert "make everything a variable"
TravisEz13 9687500
use actual runtime, not hardcoded values
TravisEz13 65c5c98
create exe wrapper tests
TravisEz13 ea427c2
publish test results
TravisEz13 82c8855
try work around warning
TravisEz13 573a17b
Update Product Name
TravisEz13 6c60c46
Update test/packaging/windows/exe.tests.ps1
TravisEz13 e65514b
Apply suggestions from code review
TravisEz13 a6dff5f
Use param patter for $PWD
TravisEz13 538d9f4
Add new license file
TravisEz13 5b75813
fix current location params
TravisEz13 7f02e2f
remove unneeded workaround
TravisEz13 97886e4
Update license
TravisEz13 002ece9
remove old license
TravisEz13 d9021b7
fix PWD in a couple of locations
TravisEz13 9c40735
update license rtf with fwlinks
TravisEz13 c038d74
update license rtf with fwlinks for privacy
TravisEz13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"> | ||
| <!-- UpgradeCode GUID MUST REMAIN SAME THROUGHOUT ALL VERSIONS, otherwise, updates won't occur. --> | ||
| <?if $(sys.BUILDARCH)=x64?> | ||
| <?define UpgradeCodePreview = "3C90221B-D500-43C6-A4A6-0BE6C2C1B317"?> | ||
| <?define UpgradeCodeRelease = "7A804CBB-648E-4276-9A58-081862DB1B99"?> | ||
| <?if $(var.IsPreview)=True?> | ||
| <?define UpgradeCode = $(var.UpgradeCodePreview)?> | ||
| <?else?> | ||
| <?define UpgradeCode = $(var.UpgradeCodeRelease)?> | ||
| <?endif?> | ||
| <?else?> | ||
| <?define UpgradeCodePreview = "4A699A9C-E904-4024-BCD2-44E098A8C6BD"?> | ||
| <?define UpgradeCodeRelease = "ED46CB02-64B3-43FD-A63E-6CF269D8C21C"?> | ||
| <?if $(var.IsPreview)=True?> | ||
| <?define UpgradeCode = $(var.UpgradeCodePreview)?> | ||
| <?else?> | ||
| <?define UpgradeCode = $(var.UpgradeCodeRelease)?> | ||
| <?endif?> | ||
| <?endif?> | ||
|
|
||
| <Bundle Name="PowerShell $(var.WindowsVersion)-$(sys.BUILDARCH)" Version="$(var.WindowsVersion)" Manufacturer="Microsoft Corporation" UpgradeCode="$(var.UpgradeCode)"> | ||
| <!-- See https://wixtoolset.org/documentation/manual/v3/bundle/wixstdba/ for a list of WiX standard bootstrapper types. --> | ||
| <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense"> | ||
| <bal:WixStandardBootstrapperApplication LicenseFile="assets\wix\ExeLicense.rtf" LogoFile="assets\ps_black_32x32.ico" /> | ||
| </BootstrapperApplicationRef> | ||
| <Chain> | ||
| <MsiPackage SourceFile="$(var.TargetPath)" Compressed="yes" /> | ||
| </Chain> | ||
| </Bundle> | ||
| </Wix> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| Describe -Name "Windows EXE" -Fixture { | ||
| BeforeAll { | ||
| function Test-Elevated { | ||
| [CmdletBinding()] | ||
| [OutputType([bool])] | ||
| Param() | ||
|
|
||
| # if the current Powershell session was called with administrator privileges, | ||
| # the Administrator Group's well-known SID will show up in the Groups for the current identity. | ||
| # Note that the SID won't show up unless the process is elevated. | ||
| return (([Security.Principal.WindowsIdentity]::GetCurrent()).Groups -contains "S-1-5-32-544") | ||
| } | ||
|
|
||
| function Invoke-ExeInstaller { | ||
| param( | ||
| [Parameter(ParameterSetName = 'Install', Mandatory)] | ||
| [Switch]$Install, | ||
|
|
||
| [Parameter(ParameterSetName = 'Uninstall', Mandatory)] | ||
| [Switch]$Uninstall, | ||
|
|
||
| [Parameter(Mandatory)] | ||
| [ValidateScript({Test-Path -Path $_})] | ||
| [String]$ExePath | ||
| ) | ||
| $action = "$($PSCmdlet.ParameterSetName)ing" | ||
| if ($Install) { | ||
| $switch = '/install' | ||
| } else { | ||
| $switch = '/uninstall' | ||
| } | ||
|
|
||
| $installProcess = Start-Process -wait $ExePath -ArgumentList $switch, '/quiet', '/norestart' -PassThru | ||
| if ($installProcess.ExitCode -ne 0) { | ||
| $exitCode = $installProcess.ExitCode | ||
| throw "$action EXE failed and returned error code $exitCode." | ||
| } | ||
| } | ||
|
|
||
| $exePath = $env:PsExePath | ||
| $channel = $env:PSMsiChannel | ||
| $runtime = $env:PSMsiRuntime | ||
|
|
||
| # Get any existing powershell in the path | ||
| $beforePath = @(([System.Environment]::GetEnvironmentVariable('PATH', 'MACHINE')) -split ';' | | ||
| Where-Object {$_ -like '*files\powershell*'}) | ||
|
|
||
| foreach ($pathPart in $beforePath) { | ||
| Write-Warning "Found existing PowerShell path: $pathPart" | ||
| } | ||
|
|
||
| if (!(Test-Elevated)) { | ||
| Write-Warning "Tests must be elevated" | ||
| } | ||
| } | ||
| BeforeEach { | ||
| $error.Clear() | ||
| } | ||
|
|
||
| Context "$Channel-$Runtime" { | ||
| BeforeAll { | ||
| Write-Verbose "cr-$channel-$runtime" -Verbose | ||
| switch ("$channel-$runtime") { | ||
| "preview-win7-x64" { | ||
| $msiUpgradeCode = '39243d76-adaf-42b1-94fb-16ecf83237c8' | ||
| } | ||
| "stable-win7-x64" { | ||
| $msiUpgradeCode = '31ab5147-9a97-4452-8443-d9709f0516e1' | ||
| } | ||
| "preview-win7-x86" { | ||
| $msiUpgradeCode = '86abcfbd-1ccc-4a88-b8b2-0facfde29094' | ||
| } | ||
| "stable-win7-x86" { | ||
| $msiUpgradeCode = '1d00683b-0f84-4db8-a64f-2f98ad42fe06' | ||
| } | ||
| default { | ||
| throw "'$_' not a valid channel runtime combination" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| It "$Channel MSI should not be installed before test" -Skip:(!(Test-Elevated)) { | ||
| $result = @(Get-CimInstance -Query "SELECT Value FROM Win32_Property WHERE Property='UpgradeCode' and Value = '{$msiUpgradeCode}'") | ||
| $result.Count | Should -Be 0 -Because "Query should return nothing if $channel $runtime is not installed" | ||
| } | ||
|
|
||
| It "EXE should install without error" -Skip:(!(Test-Elevated)) { | ||
| { | ||
| Invoke-ExeInstaller -Install -ExePath $exePath | ||
| } | Should -Not -Throw | ||
| } | ||
|
|
||
| It "Upgrade code should be correct" -Skip:(!(Test-Elevated)) { | ||
| $result = @(Get-CimInstance -Query "SELECT Value FROM Win32_Property WHERE Property='UpgradeCode' and Value = '{$msiUpgradeCode}'") | ||
| $result.Count | Should -Be 1 -Because "Query should return 1 result if Upgrade code is for $runtime $channel" | ||
| } | ||
|
|
||
| It "MSI should have updated path" -Skip:(!(Test-Elevated)) { | ||
| if ($channel -eq 'preview') { | ||
| $pattern = '*files*\powershell*\preview*' | ||
| } else { | ||
| $pattern = '*files*\powershell*' | ||
| } | ||
|
|
||
| $psPath = ([System.Environment]::GetEnvironmentVariable('PATH', 'MACHINE')) -split ';' | | ||
| Where-Object { $_ -like $pattern -and $_ -notin $beforePath } | ||
|
|
||
| if (!$psPath) { | ||
| ([System.Environment]::GetEnvironmentVariable('PATH', 'MACHINE')) -split ';' | | ||
| Where-Object { $_ -notin $beforePath } | | ||
| ForEach-Object { Write-Verbose -Verbose $_ } | ||
| } | ||
|
|
||
| $psPath | Should -Not -BeNullOrEmpty | ||
| } | ||
|
|
||
| It "MSI should uninstall without error" -Skip:(!(Test-Elevated)) { | ||
| { | ||
| Invoke-ExeInstaller -Uninstall -ExePath $exePath | ||
| } | Should -Not -Throw | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.