Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a52ce13
Add mu opt out code
TravisEz13 Jul 6, 2021
a01db86
fix key
TravisEz13 Jul 6, 2021
bd59708
fix dup key
TravisEz13 Jul 6, 2021
e1a4ce7
fix radio
TravisEz13 Jul 6, 2021
a777c86
fix dialgo formatting
TravisEz13 Jul 6, 2021
276cf72
Split the to action out
TravisEz13 Jul 6, 2021
2da1998
fix property names
TravisEz13 Jul 6, 2021
52fd3b8
fix formatting second try
TravisEz13 Jul 7, 2021
ce91ad8
use our own fwlink
TravisEz13 Jul 7, 2021
513cef8
fix formatting refinement
TravisEz13 Jul 7, 2021
b130918
change to fix functionality issue
TravisEz13 Jul 7, 2021
ff4b171
Add tests
TravisEz13 Jul 7, 2021
17db1a4
turn off strict mode
TravisEz13 Jul 7, 2021
a8a60c2
fix re-enabling strict mode
TravisEz13 Jul 7, 2021
74fc742
try to fix tests
TravisEz13 Jul 7, 2021
ec44127
try to fix tests
TravisEz13 Jul 8, 2021
5493428
continue when we have build or test error
TravisEz13 Jul 8, 2021
9529737
capture MSI log on failure
TravisEz13 Jul 8, 2021
c10dd6a
Revert "continue when we have build or test error"
TravisEz13 Jul 8, 2021
5224454
always push artifacts
TravisEz13 Jul 8, 2021
3bb7930
don't uninstall before executing tests
TravisEz13 Jul 8, 2021
0e13ff0
add uploading logs to other tests
TravisEz13 Jul 8, 2021
6b35a3b
make sure you can tell which file is which
TravisEz13 Jul 8, 2021
1c14ed2
fix up test cases
TravisEz13 Jul 8, 2021
c02fb38
Enabling MU is not working in
TravisEz13 Jul 9, 2021
e48f937
remove debug message
TravisEz13 Jul 9, 2021
43caff8
fix x86
TravisEz13 Jul 9, 2021
2ea55f4
add mu warning dialog
TravisEz13 Jul 13, 2021
d4fe879
remove tests that don't work
TravisEz13 Jul 13, 2021
f7d9d93
Fix issues found in manual testing
TravisEz13 Jul 13, 2021
0b95775
fix xml syntax
TravisEz13 Jul 13, 2021
27def49
suppress ice40
TravisEz13 Jul 13, 2021
ecc568a
try to fix condition
TravisEz13 Jul 13, 2021
a1fd7f4
Try moving properties to product
TravisEz13 Jul 13, 2021
b09d26e
add property ref
TravisEz13 Jul 13, 2021
51b80e8
Revert "Try moving properties to product"
TravisEz13 Jul 13, 2021
509f592
try random stuff
TravisEz13 Jul 13, 2021
bae1cfc
Revert "try random stuff"
TravisEz13 Jul 13, 2021
392a0f8
remove >
TravisEz13 Jul 13, 2021
cf1f4e9
try heath's suggestion
TravisEz13 Jul 13, 2021
167bbef
Add textbox with warning
TravisEz13 Jul 14, 2021
a165660
try to fix textbox logic
TravisEz13 Jul 14, 2021
9248c9f
Add dialog as checkbox event
TravisEz13 Jul 14, 2021
689a51f
try different logic for textbox
TravisEz13 Jul 14, 2021
047e4b9
Add simple logic edit box
TravisEz13 Jul 14, 2021
f5309a8
remove all dynamic warning and make static
TravisEz13 Jul 14, 2021
3c8da99
remove periods from end of hyperlinks
TravisEz13 Jul 14, 2021
4954d34
remove dead code
TravisEz13 Jul 14, 2021
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
59 changes: 57 additions & 2 deletions assets/wix/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@
Execute="deferred"
Return="ignore"
Impersonate="no" />
<SetProperty Id="EnableMU"
Before="EnableMU"
Sequence="execute"
Value="&quot;[VersionFolder]pwsh.exe&quot; -NoProfile -ExecutionPolicy Bypass -Command &quot;$null=(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2('7971f918-a847-4430-9279-4a52d1efe18d', 7, '')&quot;" />
<CustomAction Id="EnableMU"
BinaryKey="WixCA"
DllEntry="CAQuietExec"
Execute="deferred"
Return="ignore"
Impersonate="no" />
<InstallExecuteSequence>
<!-- Do not remove shortcuts on upgrade to preserve user shortcuts pinned to Taskbar, see https://stackoverflow.com/a/33402698/1810304 -->
<RemoveShortcuts>Installed AND NOT UPGRADINGPRODUCTCODE</RemoveShortcuts>
Expand All @@ -93,6 +103,9 @@
<Custom Action="EnablePSRemoting" After="InstallFiles">
<![CDATA[NOT Installed AND (ENABLE_PSREMOTING=1)]]>
</Custom>
<Custom Action="EnableMU" After="InstallFiles">
<![CDATA[NOT Installed AND (ENABLE_MU=1)]]>
</Custom>
</InstallExecuteSequence>
<UI>
<Dialog Id="MyExitDialog" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">
Expand Down Expand Up @@ -135,6 +148,7 @@
<Feature Id="ProductFeature" Title="PowerShell" Level="1">
<ComponentGroupRef Id="ApplicationFiles"/>
<ComponentRef Id="ApplicationProgramsMenuShortcut"/>
<ComponentRef Id="MURegistryEntries"/>
<ComponentRef Id="RegistryEntries"/>
<ComponentRef Id="SharedRegistryEntries"/>
<ComponentRef Id="SetPath"/>
Expand Down Expand Up @@ -176,6 +190,13 @@
<!-- Should retain component GUID since this is a shared, non-file, non-registry resource. -->
<Environment Id="PowerShellDistributionChannel" Action="create" Name="POWERSHELL_DISTRIBUTION_CHANNEL" Permanent="no" System="yes" Value="MSI:[WINDOWS_PRODUCT_NAME]"/>
</Component>
<Component Id="MURegistryEntries">
<Condition>USE_MU=1</Condition>
<!-- Create registry key to allow opt-out of MU servicing without opting out of MU completely. -->
<RegistryKey Root="HKLM" Key="Software\Microsoft\PowerShellCore" Action="create" ForceCreateOnInstall="yes">
<RegistryValue Type="integer" Value="1" Name="UseMU" KeyPath="yes"/>
</RegistryKey>
</Component>
<Component Id="RegistryEntries">
<!-- 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 -->
Expand Down Expand Up @@ -317,6 +338,37 @@
</UI>
</Fragment>

<!-- Microsoft Update Menu Dialog -->
<Fragment>
<UI>
<Property Id="USE_MU" Value="1" />
<Property Id="ENABLE_MU" Value="1" />
<Dialog Id="MuDialog" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">
<!-- Banner -->
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="yes" Text="!(loc.InstallDirDlgBannerBitmap)"/>
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="30" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Use Microsoft Update to help keep your computer secure and up to date" TabSkip="yes" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" TabSkip="yes" />
<Control Id="Description" Type="Text" X="25" Y="54" Width="280" Height="100" Transparent="yes" NoPrefix="yes" Text="Microsoft Update helps keep your computer secure and up to date for Windows and other Microsoft products, including PowerShell 7. Updates will be delivered based on your current update settings. You can review or change these settings from the Windows Update control panel." TabSkip="yes" />
<!-- If the checkboxes are defined first, then they are first in the tab order and can be ticked and unticked using the spacebar -->
<Control Id="UseMuCheckBox" Type="CheckBox" X="20" Y="100" Width="290" Height="27" Property="USE_MU" Text="Enable updating PowerShell through Microsft Update or WSUS (recommended)"/>
<Control Id="EnableMuCheckBox" Type="CheckBox" X="20" Y="130" Width="290" Height="17" Property="ENABLE_MU" Text="Use Microsoft Update when I check for updates (recommended)"/>
<Control Id="MuWarningText" Type="Text" X="20" Y="160" Width="290" Height="27" Text="Without Microsoft Update enabled, you will need to use another update solution like WSUS or SCCM in order to receive automatic updates."/>
<Control Id="MuFAQ" Type="Hyperlink" X="20" Y="190" Width="214" Height="17">
<Text><![CDATA[<a href="https://aka.ms/PowerShell-Microsoft-Update-FAQ">See the Microsoft Update FAQ</a>]]></Text>
</Control>
<Control Id="PrivacyLink" Type="Hyperlink" X="20" Y="210" Width="290" Height="17">
<Text><![CDATA[<a href="https://aka.ms/PowerShell-Microsoft-Update-Privacy-Statement">Read the Microsoft Update Priacy Statement</a>]]></Text>
</Control>
<!-- divider and bottom buttons -->
<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)">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
</Dialog>
</UI>
</Fragment>
<!-- 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">
Expand All @@ -325,6 +377,7 @@
- WixUI_WelcomeDlg
- WixUI_InstallDirDlg
- ExplorerContextMenuDialog
- MuDialog
- WixUI_VerifyReadyDlg
- WixUI_DiskCostDlg
Maintenance dialog sequence:
Expand Down Expand Up @@ -364,7 +417,9 @@
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>

<Publish Dialog="ExplorerContextMenuDialog" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="ExplorerContextMenuDialog" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
<Publish Dialog="ExplorerContextMenuDialog" Control="Next" Event="NewDialog" Value="MuDialog">1</Publish>
<Publish Dialog="MuDialog" Control="Back" Event="NewDialog" Value="ExplorerContextMenuDialog">1</Publish>
<Publish Dialog="MuDialog" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="2">1</Publish>

<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
Expand All @@ -375,7 +430,7 @@
<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="MuDialog" 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
82 changes: 74 additions & 8 deletions test/packaging/windows/msi.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Describe -Name "Windows MSI" -Fixture {
BeforeAll {
Set-StrictMode -Off
function Test-Elevated {
[CmdletBinding()]
[OutputType([bool])]
Expand All @@ -14,6 +15,43 @@ Describe -Name "Windows MSI" -Fixture {
return (([Security.Principal.WindowsIdentity]::GetCurrent()).Groups -contains "S-1-5-32-544")
}

function Test-IsMuEnabled {
$sm = (New-Object -ComObject Microsoft.Update.ServiceManager)
$mu = $sm.Services | Where-Object { $_.ServiceId -eq '7971f918-a847-4430-9279-4a52d1efe18d' }
if ($mu) {
return $true
}
return $false
}

function Invoke-TestAndUploadLogOnFailure {
param (
[scriptblock] $Test
)

try {
& $Test
}
catch {
Send-VstsLogFile -Path $msiLog
throw
}
}

function Get-UseMU {
$useMu = 0
$key = 'HKLM:\SOFTWARE\Microsoft\PowerShellCore\'
if ($runtime -like '*x86*') {
$key = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\PowerShellCore\'
}

try {
$useMu = Get-ItemPropertyValue -Path $key -Name UseMU -ErrorAction SilentlyContinue
} catch {}

return $useMu
}

function Invoke-Msiexec {
param(
[Parameter(ParameterSetName = 'Install', Mandatory)]
Expand Down Expand Up @@ -45,6 +83,7 @@ Describe -Name "Windows MSI" -Fixture {
}

$argumentList = "$switch $MsiPath /quiet /l*vx $msiLog $additionalOptions"
Write-Verbose -Message "running msiexec $argumentList"
$msiExecProcess = Start-Process msiexec.exe -Wait -ArgumentList $argumentList -NoNewWindow -PassThru
if ($msiExecProcess.ExitCode -ne 0) {
$exitCode = $msiExecProcess.ExitCode
Expand All @@ -55,6 +94,7 @@ Describe -Name "Windows MSI" -Fixture {
$msiX64Path = $env:PsMsiX64Path
$channel = $env:PSMsiChannel
$runtime = $env:PSMsiRuntime
$muEnabled = Test-IsMuEnabled

# Get any existing powershell in the path
$beforePath = @(([System.Environment]::GetEnvironmentVariable('PATH', 'MACHINE')) -split ';' |
Expand All @@ -71,16 +111,14 @@ Describe -Name "Windows MSI" -Fixture {
}
$uploadedLog = $false
}

AfterAll {
Set-StrictMode -Version 3.0
}

BeforeEach {
$error.Clear()
}
AfterEach {
if ($error.Count -ne 0 -and !$uploadedLog) {
Copy-Item -Path $msiLog -Destination $env:temp -Force
Write-Verbose "MSI log is at $env:temp\msilog.txt" -Verbose
$uploadedLog = $true
}
}

Context "Upgrade code" {
BeforeAll {
Expand Down Expand Up @@ -149,7 +187,7 @@ Describe -Name "Windows MSI" -Fixture {
Context "Add Path disabled" {
It "MSI should install without error" -Skip:(!(Test-Elevated)) {
{
Invoke-MsiExec -Install -MsiPath $msiX64Path -Properties @{ADD_PATH = 0}
Invoke-MsiExec -Install -MsiPath $msiX64Path -Properties @{ADD_PATH = 0; USE_MU = 1; ENABLE_MU = 1}
} | Should -Not -Throw
}

Expand All @@ -160,6 +198,34 @@ Describe -Name "Windows MSI" -Fixture {
$psPath | Should -BeNullOrEmpty
}

It "UseMU should be 1" -Skip:(!(Test-Elevated)) {
Invoke-TestAndUploadLogOnFailure -Test {
$useMu = Get-UseMU
$useMu | Should -Be 1
}
}

It "MSI should uninstall without error" -Skip:(!(Test-Elevated)) {
{
Invoke-MsiExec -Uninstall -MsiPath $msiX64Path
} | Should -Not -Throw
}
}

Context "USE_MU disabled" {
It "MSI should install without error" -Skip:(!(Test-Elevated)) {
{
Invoke-MsiExec -Install -MsiPath $msiX64Path -Properties @{USE_MU = 0}
} | Should -Not -Throw
}

It "UseMU should be 0" -Skip:(!(Test-Elevated)) {
Invoke-TestAndUploadLogOnFailure -Test {
$useMu = Get-UseMU
$useMu | Should -Be 0
}
}

It "MSI should uninstall without error" -Skip:(!(Test-Elevated)) {
{
Invoke-MsiExec -Uninstall -MsiPath $msiX64Path
Expand Down
11 changes: 5 additions & 6 deletions test/tools/Modules/HelpersCommon/HelpersCommon.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -219,22 +219,21 @@ function Send-VstsLogFile {
}
}

$newName = ([System.Io.Path]::GetRandomFileName() + "-$LogName.txt")
if($Contents)
{
$logFile = Join-Path -Path $logFolder -ChildPath ([System.Io.Path]::GetRandomFileName() + "-$LogName.txt")
$name = Split-Path -Leaf -Path $logFile
$logFile = Join-Path -Path $logFolder -ChildPath $newName

$Contents | Out-File -path $logFile -Encoding ascii
}
else
{
$name = Split-Path -Leaf -Path $path
$logFile = Join-Path -Path $logFolder -ChildPath ([System.Io.Path]::GetRandomFileName() + '-' + $name)
$logFile = Join-Path -Path $logFolder -ChildPath $newName
Copy-Item -Path $Path -Destination $logFile
}

Write-Host "##vso[artifact.upload containerfolder=$name;artifactname=$name]$logFile"
Write-Verbose "Log file captured as $name" -Verbose
Write-Host "##vso[artifact.upload containerfolder=$newName;artifactname=$newName]$logFile"
Write-Verbose "Log file captured as $newName" -Verbose
}

# Tests if the Linux or macOS user is root
Expand Down
14 changes: 6 additions & 8 deletions tools/ci.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -546,23 +546,21 @@ function Invoke-CIFinish
Start-PSBuild -Restore -Runtime win-arm64 -PSModuleRestore -Configuration 'Release' -ReleaseTag $releaseTag
$arm64Package = Start-PSPackage -Type zip -WindowsRuntime win-arm64 -ReleaseTag $releaseTag -SkipReleaseChecks
$artifacts.Add($arm64Package)

}
finally {
$pushedAllArtifacts = $true

$artifacts | ForEach-Object {
Write-Log -Message "Pushing $_ as CI artifact"
if(Test-Path $_)
{
if (Test-Path $_) {
Push-Artifact -Path $_ -Name 'artifacts'
}
else
{
} else {
$pushedAllArtifacts = $false
Write-Warning "Artifact $_ does not exist."
}
}
if(!$pushedAllArtifacts)
{

if (!$pushedAllArtifacts) {
throw "Some artifacts did not exist!"
}
}
Expand Down
3 changes: 2 additions & 1 deletion tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3278,7 +3278,8 @@ function Start-MsiBuild {
Write-Log "running light..."
# suppress ICE61, because we allow same version upgrades
# suppress ICE57, this suppresses an error caused by our shortcut not being installed per user
Start-NativeExecution -VerboseOutputOnError {& $wixPaths.wixLightExePath -sice:ICE61 -sice:ICE57 -out $msiLocationPath -pdbout $msiPdbLocationPath $objectPaths $extensionArgs }
# suppress ICE40, REINSTALLMODE is defined in the Property table.
Start-NativeExecution -VerboseOutputOnError {& $wixPaths.wixLightExePath -sice:ICE61 -sice:ICE40 -sice:ICE57 -out $msiLocationPath -pdbout $msiPdbLocationPath $objectPaths $extensionArgs }

foreach($file in $objectPaths)
{
Expand Down