forked from ktorio/ktor-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packInstaller.ps1
46 lines (38 loc) · 1.94 KB
/
packInstaller.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
param (
[string]$toolPath = ".\build\windows\amd64\ktor.exe",
[string]$outPath = "ktor-installer.msi",
[string]$wixExe = "wix.exe"
)
$version = $(git describe --tags --contains --always --abbrev=7)
if (!($version -match '\d+\.\d+.\d+')) {
Write-Error "Expected version in the format *.*.*, got ${version}"
exit 1
}
$wixProduct = @"
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
<Package Name="Ktor CLI" Version="${version}" Manufacturer="JetBrains" UpgradeCode="$(New-Guid)" Scope='perUser'>
<MediaTemplate EmbedCab="yes" />
<WixVariable Id="WixUILicenseRtf" Value="LICENSE.rtf" />
<MajorUpgrade
AllowDowngrades="no" DowngradeErrorMessage="A newer version of Ktor CLI is already installed"
AllowSameVersionUpgrades="yes"
/>
<Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="Ktor CLI has been successfully installed. Use the ktor.exe alias on the command line to launch the tool." />
<StandardDirectory Id="LocalAppDataFolder">
<Directory Id="JetBrains" Name="JetBrains">
<Directory Id="INSTALLDIR" Name="KtorCLI">
<Component Id="MainExecutable" Guid="$(New-Guid)">
<Environment Id="PATH" Name="PATH" Value="[INSTALLDIR]" Permanent="yes" Part="last" Action="set" System="no" />
<File Id="KtorExe" Name="ktor.exe" DiskId="1" Source="${toolPath}" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</StandardDirectory>
<ui:WixUI Id="WixUI_InstallDir" InstallDirectory="INSTALLDIR" />
</Package>
</Wix>
"@
$wixProduct | out-file -filepath KtorProduct.wxs
& $wixExe build -arch x64 -o $outPath -ext WixToolset.UI.wixext KtorProduct.wxs
(Get-FileHash -Path $outPath -Algorithm Sha256).Hash | out-file checksum.txt -NoNewline
Remove-Item KtorProduct.wxs