installer/build.ps1: autoformat

This commit is contained in:
Martin Lindhe 2018-03-14 11:12:02 +01:00
parent 191debeed6
commit cede267565
1 changed files with 24 additions and 24 deletions

View File

@ -1,12 +1,12 @@
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)]
[String] $PathToExecutable,
[Parameter(Mandatory=$true)]
[String] $Version,
[Parameter(Mandatory=$false)]
[ValidateSet("amd64","386")]
[String] $Arch = "amd64"
[Parameter(Mandatory = $true)]
[String] $PathToExecutable,
[Parameter(Mandatory = $true)]
[String] $Version,
[Parameter(Mandatory = $false)]
[ValidateSet("amd64", "386")]
[String] $Arch = "amd64"
)
$ErrorActionPreference = "Stop"
@ -15,32 +15,32 @@ $PathToExecutable = Resolve-Path $PathToExecutable
# Set working dir to this directory, reset previous on exit
Push-Location $PSScriptRoot
Trap {
# Reset working dir on error
Pop-Location
# Reset working dir on error
Pop-Location
}
if ($PSVersionTable.PSVersion.Major -lt 5) {
Write-Error "Powershell version 5 required"
exit 1
Write-Error "Powershell version 5 required"
exit 1
}
$wc = New-Object System.Net.WebClient
function Get-FileIfNotExists {
Param (
$Url,
$Destination
)
if(-not (Test-Path $Destination)) {
Write-Verbose "Downloading $Url"
$wc.DownloadFile($Url, $Destination)
}
else {
Write-Verbose "${Destination} already exists. Skipping."
}
Param (
$Url,
$Destination
)
if (-not (Test-Path $Destination)) {
Write-Verbose "Downloading $Url"
$wc.DownloadFile($Url, $Destination)
}
else {
Write-Verbose "${Destination} already exists. Skipping."
}
}
$sourceDir = mkdir -Force Source
mkdir -Force Work,Output | Out-Null
mkdir -Force Work, Output | Out-Null
Write-Verbose "Downloading WiX..."
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
@ -51,7 +51,7 @@ Expand-Archive -Path "${sourceDir}\wix-binaries.zip" -DestinationPath WiX -Force
Copy-Item -Force $PathToExecutable Work/wmi_exporter.exe
Write-Verbose "Creating wmi_exporter-${Version}-${Arch}.msi"
$wixArch = @{"amd64"="x64"; "386"="x86"}[$Arch]
$wixArch = @{"amd64" = "x64"; "386" = "x86"}[$Arch]
$wixOpts = "-ext WixFirewallExtension"
Invoke-Expression "WiX\candle.exe -nologo -arch $wixArch $wixOpts -out Work\wmi_exporter.wixobj -dVersion=`"$Version`" wmi_exporter.wxs"
Invoke-Expression "WiX\light.exe -nologo -spdb $wixOpts -out `"Output\wmi_exporter-${Version}-${Arch}.msi`" Work\wmi_exporter.wixobj"