actions / runner-images

GitHub Actions runner images
MIT License
10.09k stars 3.04k forks source link

WiX toolkit is not in the PATH #9551

Closed kevgo closed 6 months ago

kevgo commented 6 months ago

Description

WiX provides several binaries in C:\Program Files (x86)\WiX Toolset v3.14\bin. This directory is not in the PATH environment variable.

Platforms affected

Runner images affected

Image version and build link

Image: windows-2022
  Version: 20240317.1.0
  Included Software: https://github.com/actions/runner-images/blob/win22/20240317.1/images/windows/Windows2022-Readme.md
  Image Release: https://github.com/actions/runner-images/releases/tag/win22%2F20240317.1

Is it regression?

no, it was always broken afaik

Expected behavior

C:\Program Files (x86)\WiX Toolset v3.14\bin is in the PATH. I can call executables from the WiX toolkit, like C:\Program Files (x86)\WiX Toolset v3.14\bin\candle.exe from any directory.

Actual behavior

C:\Program Files (x86)\WiX Toolset v3.14\bin is not in the PATH. I can not call executables from the WiX toolkit, like C:\Program Files (x86)\WiX Toolset v3.14\bin\candle.exe from any directory.

Repro steps

To reproduce, I try to call the candle.exe executable provided by WiX:

> candle.exe -?

'candle' is not recognized as an internal or external command,
operable program or batch file.

Checking the PATH environment variable reveals that WiX is indeed not in it:

> $env:PATH

C:\Program Files\MongoDB\Server\5.0\bin;C:\aliyun-cli;C:\vcpkg;C:\Program Files (x86)\NSIS\;C:\tools\zstd;C:\Program Files\Mercurial\;C:\hostedtoolcache\windows\stack\2.15.3\x64;C:\cabal\bin;C:\\ghcup\bin;C:\mingw64\bin;C:\Program Files\dotnet;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\R\R-4.3.2\bin\x64;C:\SeleniumWebDrivers\GeckoDriver;C:\SeleniumWebDrivers\EdgeDriver\;C:\SeleniumWebDrivers\ChromeDriver;C:\Program Files (x86)\sbt\bin;C:\Program Files (x86)\GitHub CLI;C:\Program Files\Git\bin;C:\Program Files (x86)\pipx_bin;C:\npm\prefix;C:\hostedtoolcache\windows\go\1.21.8\x64\bin;C:\hostedtoolcache\windows\Python\3.9.13\x64\Scripts;C:\hostedtoolcache\windows\Python\3.9.13\x64;C:\hostedtoolcache\windows\Ruby\3.0.6\x64\bin;C:\Program Files\OpenSSL\bin;C:\tools\kotlinc\bin;C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\8.0.402-6\x64\bin;C:\Program Files\ImageMagick-7.1.1-Q16-HDRI;C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;C:\ProgramData\kind;C:\ProgramData\Chocolatey\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\PowerShell\7\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Microsoft SQL Server\160\DTS\Binn\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\ProgramData\chocolatey\lib\pulumi\tools\Pulumi\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\CMake\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.8.7\bin;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\GitHub CLI\;c:\tools\php;C:\Program Files\Amazon\AWSCLIV2\;C:\Program Files\Amazon\SessionManagerPlugin\bin\;C:\Program Files\Amazon\AWSSAMCLI\bin\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\LLVM\bin;;C:\Users\runneradmin\.dotnet\tools;C:\Users\runneradmin\.cargo\bin;C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps;C:\Program Files\go-msi\

Running $env:PATH = "$env:PATH;C:\Program Files (x86)\WiX Toolset v3.14\bin" fixes the issue:

> candle.exe -?

LicenseAgreementDlg_HK.wxs WixUI_HK.wxs product.wxs 
Windows Installer XML Toolset Compiler version 3.14.0.8606
Copyright (c) .NET Foundation and contributors. All rights reserved.
sergei-pyshnoi commented 6 months ago

Hello @kevgo . Thanks for your report. We will take a look.

lzandman commented 6 months ago

The WiX Toolset installer adds a WIX environment variable that points to the WiX install directory. On my current test runner it contains this value: WIX=C:\Program Files (x86)\WiX Toolset v3.14\

So you can run WiX commands from a Command Prompt by prefixing it:

"%WIX%"\bin\candle.exe

Of course the Install-Wix.ps1 script could also be augmented. Maybe like this:

################################################################################
##  File:  Install-Wix.ps1
##  Desc:  Install WIX.
################################################################################

Install-ChocoPackage wixtoolset -ArgumentList "--force"

# Add WiX to the PATH
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "Machine")
# Choose one of these next two lines, depending on the WiX priority
$NewPath = "$($Env:WIX)\bin;$currentPath"
#$NewPath = "$currentPath;$($Env:WIX)\bin"

[Environment]::SetEnvironmentVariable("PATH", $NewPath, "Machine")

Invoke-PesterTests -TestFile "Wix"
kevgo commented 6 months ago

Thanks for looking into this! 🙏 I do not call the WiX binaries directly, but am using a third-party application to generate the Windows installer for my app. This third-party app calls the various WiX binaries for me. It is not aware of the WIX env variable and requires (rightfully imo) that I add the wix bin directory to the PATH.

In addition to the WIX env variable, I suggest adding the WiX binaries to the PATH so that they can be called idiomatically.

Btw please don't forget that the binaries are in the bin subfolder:

$NewPath = "$($Env:WIX + "\bin");$currentPath"
lzandman commented 6 months ago

Btw please don't forget that the binaries are in the bin subfolder:

Oops, I indeed forgot to add the bin folder to my Powershell code. I updated my post.

mikhailkoliada commented 6 months ago

Deployed.