2016-09-16 06:36:58 +00:00
|
|
|
[CmdletBinding()]
|
|
|
|
Param (
|
2018-03-14 10:12:02 +00:00
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
[String] $PathToExecutable,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
[String] $Version,
|
|
|
|
[Parameter(Mandatory = $false)]
|
2024-01-08 18:59:15 +00:00
|
|
|
[ValidateSet("amd64", "arm64")]
|
2018-03-14 10:12:02 +00:00
|
|
|
[String] $Arch = "amd64"
|
2016-09-16 06:36:58 +00:00
|
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
2024-05-11 22:24:52 +00:00
|
|
|
# The MSI version is not semver compliant, so just take the numerical parts
|
2024-05-12 10:25:06 +00:00
|
|
|
$MsiVersion = $Version -replace '^v?([0-9\.]+).*$','$1'
|
2024-05-11 22:24:52 +00:00
|
|
|
|
2016-09-16 06:36:58 +00:00
|
|
|
# Get absolute path to executable before switching directories
|
|
|
|
$PathToExecutable = Resolve-Path $PathToExecutable
|
|
|
|
# Set working dir to this directory, reset previous on exit
|
|
|
|
Push-Location $PSScriptRoot
|
|
|
|
Trap {
|
2018-03-14 10:12:02 +00:00
|
|
|
# Reset working dir on error
|
|
|
|
Pop-Location
|
2016-09-16 06:36:58 +00:00
|
|
|
}
|
|
|
|
|
2023-11-17 20:53:54 +00:00
|
|
|
mkdir -Force Work | Out-Null
|
2020-05-24 18:42:23 +00:00
|
|
|
Copy-Item -Force $PathToExecutable Work/windows_exporter.exe
|
2016-09-16 06:36:58 +00:00
|
|
|
|
2020-05-24 18:42:23 +00:00
|
|
|
Write-Verbose "Creating windows_exporter-${Version}-${Arch}.msi"
|
2024-01-08 18:59:15 +00:00
|
|
|
$wixArch = @{"amd64" = "x64"; "arm64" = "arm64"}[$Arch]
|
2024-04-20 21:29:38 +00:00
|
|
|
|
2024-09-06 20:29:50 +00:00
|
|
|
Invoke-Expression "wix build -arch $wixArch -o .\windows_exporter-$($Version)-$($Arch).msi .\files.wxs .\main.wxs -d ProductName=windows_exporter -d Version=$($MsiVersion) -ext WixToolset.Firewall.wixext -ext WixToolset.UI.wixext -ext WixToolset.Util.wixext"
|
2016-09-16 06:36:58 +00:00
|
|
|
|
|
|
|
Write-Verbose "Done!"
|
2017-03-17 18:23:03 +00:00
|
|
|
Pop-Location
|