#!/usr/bin/env bash # Builds dist/SQLInsight-Pro--x64.msi on Linux with wixl (apt install wixl). # installer/build-msi.sh 1.2.0 # The programs are published self-contained for win-x64, so the servers need no .NET runtime. set -euo pipefail VERSION="${1:-1.0.0}" # Windows Installer only knows numeric versions (major.minor.build): 1.3.0-preview.1 is installed as 1.3.0. MSI_VERSION="${VERSION%%[-+]*}" ROOT="$(cd "$(dirname "$0")/.." && pwd)" OUT="$ROOT/artifacts/msi" PUBLISH="$OUT/publish" DIST="$ROOT/dist" command -v wixl >/dev/null || { echo "wixl mangler: apt install wixl" >&2; exit 1; } # wixl writes a codepage-neutral database, where only ASCII is safe: keep installer texts in English/ASCII. if LC_ALL=C grep -n '[^ -~ ]' "$ROOT/installer/SQLInsight.wxs" "$ROOT/installer/SettingsDlg.wxs"; then echo "installer/SQLInsight.wxs må kun indeholde ASCII (se linjerne ovenfor)" >&2; exit 1 fi rm -rf "$OUT" && mkdir -p "$PUBLISH" "$DIST" for app in Agent Web; do dotnet publish "$ROOT/src/SQLInsight.$app" -c Release -r win-x64 --self-contained true \ -p:Version="$VERSION" -p:DebugType=none -p:GenerateDocumentationFile=false -o "$PUBLISH/$app" --nologo -v quiet done # One component per file. The exe (service key path) and appsettings.json (kept on upgrade) are authored by hand. harvest() { local app="$1" dir="$2" group="$3" (cd "$PUBLISH" && find "$app" -type f \ ! -name "SQLInsight.$app.exe" ! -name "appsettings.json" ! -name "appsettings.*.json" | sort) \ | wixl-heat --prefix "$app/" --directory-ref "$dir" --component-group "$group" --var "var.${app}Dir" --win64 \ | sed -E "s/Id=\"(cmp|fil|dir)/Id=\"\1${app}/g" \ > "$OUT/$app.wxs" } harvest Agent AGENTDIR AgentFiles harvest Web WEBDIR WebFiles # wixl cannot parse component conditions; they (and Permanent/NeverOverwrite) are written into the MSI afterwards. python3 "$ROOT/installer/msi-tables.py" strip "$ROOT/installer/SQLInsight.wxs" "$OUT/SQLInsight.wxs" MSI="$DIST/SQLInsight-Pro-$VERSION-x64.msi" cd "$ROOT/installer" wixl --arch x64 --ext ui \ -D Win64=yes -D Version="$MSI_VERSION" -D AgentDir="$PUBLISH/Agent" -D WebDir="$PUBLISH/Web" -D InstallerDir="$ROOT/installer" \ -o "$MSI" "$OUT/SQLInsight.wxs" "$ROOT/installer/SettingsDlg.wxs" "$OUT/Agent.wxs" "$OUT/Web.wxs" 2> >(grep -v "has no property named" >&2) python3 "$ROOT/installer/msi-tables.py" apply "$ROOT/installer/SQLInsight.wxs" "$MSI" # SQLInsight artwork instead of the default dialog pictures. msibuild "$MSI" -a Binary.WixUI_Bmp_Dialog "$ROOT/installer/dialog.bmp" -a Binary.WixUI_Bmp_Banner "$ROOT/installer/banner.bmp" python3 "$ROOT/installer/verify-msi.py" "$MSI" echo "$MSI"