Chris@2448: Chris@2448: Set-StrictMode -Version 2.0 Chris@2448: $ErrorActionPreference = "Stop" Chris@2448: Chris@2485: $redist_parent_dir = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\" Chris@2485: Chris@2485: $redists = (Get-ChildItem -Path $redist_parent_dir -Name -Include 14.* -Attributes Directory) Chris@2485: Chris@2485: if (!$redists) { Chris@2485: echo "ERROR: No 14.x redistributable directories found under $redist_parent_dir" Chris@2485: exit 1 Chris@2485: } Chris@2485: Chris@2485: $redist_ver = $redists[-1] Chris@2485: Chris@2549: $version = (Get-Content version.h) -replace '#define SV_VERSION ','' -replace '"','' -replace '-pre.*','' Chris@2448: $wxs = "deploy\win64\sonic-visualiser.wxs" Chris@2448: Chris@2448: $in = "$wxs.in" Chris@2448: Chris@2485: $redist_dir="$redist_parent_dir\$redist_ver\x64\Microsoft.VC142.CRT" Chris@2448: Chris@2448: echo "Generating $wxs..." Chris@2448: echo " ...for SV version $version" Chris@2448: echo " ...for redist version $redist_ver" Chris@2448: echo " ...from $in" Chris@2448: echo "" Chris@2448: Chris@2448: if (!(Test-Path -Path $redist_dir -PathType Container)) { Chris@2448: echo "ERROR: Redistributable directory $redist_dir not found" Chris@2448: exit 1 Chris@2448: } Chris@2448: Chris@2448: if (!(Test-Path -Path $in -PathType Leaf)) { Chris@2448: echo "ERROR: Input file $in not found" Chris@2448: exit 1 Chris@2448: } Chris@2448: Chris@2448: (Get-Content $in) -replace '@VERSION@', $version -replace '@REDIST_VER@', $redist_ver -replace '@W@', '' | Out-File -encoding ASCII $wxs Chris@2448: Chris@2448: echo "Done"