From 9690ca4c70316da4b7086bfa9f97d8ebea77d60f Mon Sep 17 00:00:00 2001 From: Erik Bershel <110455084+erik-bershel@users.noreply.github.com> Date: Fri, 29 Mar 2024 11:51:52 +0100 Subject: [PATCH] [Windows] Add WIX binaries folder to the PATH (#9582) * [Windows] Add WIX binaries folder to the PATH * Add Update-Environment, small prettifying * Move tests from script to Pester * Fix Wix tests to use Join-Path --------- Co-authored-by: Leon Zandman --- images/windows/scripts/build/Install-Wix.ps1 | 6 ++++++ images/windows/scripts/tests/Wix.Tests.ps1 | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/images/windows/scripts/build/Install-Wix.ps1 b/images/windows/scripts/build/Install-Wix.ps1 index 0fd90bf3..d94d03da 100644 --- a/images/windows/scripts/build/Install-Wix.ps1 +++ b/images/windows/scripts/build/Install-Wix.ps1 @@ -5,4 +5,10 @@ Install-ChocoPackage wixtoolset -ArgumentList "--force" +Update-Environment +$currentPath = [System.Environment]::GetEnvironmentVariable("PATH", "Machine") +$newPath = $currentPath + ";$(Join-Path -Path $env:WIX -ChildPath "bin")" +[Environment]::SetEnvironmentVariable("PATH", $newPath, "Machine") +Update-Environment + Invoke-PesterTests -TestFile "Wix" diff --git a/images/windows/scripts/tests/Wix.Tests.ps1 b/images/windows/scripts/tests/Wix.Tests.ps1 index 66937f69..cf6fc2fd 100644 --- a/images/windows/scripts/tests/Wix.Tests.ps1 +++ b/images/windows/scripts/tests/Wix.Tests.ps1 @@ -8,4 +8,17 @@ Describe "Wix" { It "Wix Toolset version from registry" { $version | Should -Not -BeNullOrEmpty } + + It "Wix variable exists" { + $env:WIX | Should -Not -BeNullOrEmpty + } + + It "Wix binaries folder exists" { + Test-Path -Path $(Join-Path -Path $env:WIX -ChildPath "bin") | Should -Be $true + } + + It "Wix binaries folder is in PATH" { + $testPath = Join-Path -Path $env:WIX -ChildPath "bin" + $env:PATH -split ";" | Should -Contain "$testPath" + } }