Skip to content
1 change: 1 addition & 0 deletions .vsts-ci/windows/windows-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pr:
- src/Microsoft.WSMan.Runtime/Microsoft.WSMan.Runtime.csproj
- src/Modules/PSGalleryModules.csproj
- src/powershell-win-core/powershell-win-core.csproj
- test/packaging/windows/*
- tools/ci.psm1
- tools/packaging/*

Expand Down
39 changes: 38 additions & 1 deletion test/packaging/windows/msi.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Describe -Name "Windows MSI" -Fixture {
}

function Get-UseMU {
$useMu = 0
$useMu = $null
$key = 'HKLM:\SOFTWARE\Microsoft\PowerShellCore\'
if ($runtime -like '*x86*') {
$key = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\PowerShellCore\'
Expand All @@ -49,6 +49,25 @@ Describe -Name "Windows MSI" -Fixture {
$useMu = Get-ItemPropertyValue -Path $key -Name UseMU -ErrorAction SilentlyContinue
} catch {}

if (!$useMu) {
$useMu = 0
}

return $useMu
}

function Set-UseMU {
param(
[int]
$Value
)
$key = 'HKLM:\SOFTWARE\Microsoft\PowerShellCore\'
if ($runtime -like '*x86*') {
$key = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\PowerShellCore\'
}

Set-ItemProperty -Path $key -Name UseMU -Value $Value -Type DWord

return $useMu
}

Expand Down Expand Up @@ -185,6 +204,15 @@ Describe -Name "Windows MSI" -Fixture {
}

Context "Add Path disabled" {
BeforeAll {
Set-UseMU -Value 0
}

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

It "MSI should install without error" -Skip:(!(Test-Elevated)) {
{
Invoke-MsiExec -Install -MsiPath $msiX64Path -Properties @{ADD_PATH = 0; USE_MU = 1; ENABLE_MU = 1}
Expand Down Expand Up @@ -213,6 +241,15 @@ Describe -Name "Windows MSI" -Fixture {
}

Context "USE_MU disabled" {
BeforeAll {
Set-UseMU -Value 0
}

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

It "MSI should install without error" -Skip:(!(Test-Elevated)) {
{
Invoke-MsiExec -Install -MsiPath $msiX64Path -Properties @{USE_MU = 0}
Expand Down