Skip to content

Commit 02046d4

Browse files
committed
Merge installer build and MSI rename into pack
1 parent 4fac093 commit 02046d4

4 files changed

Lines changed: 42 additions & 76 deletions

File tree

build/build-installer.ps1

Lines changed: 0 additions & 66 deletions
This file was deleted.

build/pack-setup.ps1

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,52 @@
1010
Write-Host ("Build started {0:yyyy.MM.dd HH:mm:ss}" -f (Get-Date))
1111

1212
$scriptRoot = $PSScriptRoot
13+
$repoRoot = [System.IO.Path]::GetFullPath((Join-Path $scriptRoot ".."))
1314
$version = git describe --always --tags --exclude latest
1415
$globalPackages = (dotnet nuget locals global-packages --list) -split ":\s*", 2 | Select-Object -Last 1
1516

1617
$sevenZip = Join-Path $globalPackages "micasetup.tools\2.5.0\build\bin\7z.exe"
1718
$makemicaPath = Join-Path $globalPackages "micasetup.tools\2.5.0\build\makemica.exe"
1819

19-
Set-Location $scriptRoot\..\
20-
dotnet restore .\src\SecondaryClick\SecondaryClick.csproj
21-
dotnet build .\src\SecondaryClick\SecondaryClick.csproj -c Release --no-restore
20+
# Installer build settings
21+
$appProject = Join-Path $repoRoot "src\SecondaryClick\SecondaryClick.csproj"
22+
$installerProject = Join-Path $repoRoot "src\SecondaryClick.Installer\SecondaryClick.Installer.wixproj"
2223

24+
Set-Location $repoRoot
25+
26+
# Build app output (used by both installer heat harvest and portable package)
27+
# Restore with Release configuration so conditional PackageReference entries (for example Costura.Fody) are included.
28+
dotnet restore $appProject -p:Configuration=Release
29+
dotnet build $appProject -c Release --no-restore
30+
31+
# Build MSI installer
32+
$vsWhereCmd = Get-Command vswhere.exe -ErrorAction SilentlyContinue
33+
if (-not $vsWhereCmd) {
34+
throw "vswhere.exe not found in PATH. Please install Visual Studio/Build Tools and ensure vswhere is available."
35+
}
36+
37+
$msbuildExe = & $vsWhereCmd.Source -latest -products * -requires Microsoft.Component.MSBuild -find "MSBuild\**\Bin\MSBuild.exe" | Select-Object -First 1
38+
if ([string]::IsNullOrWhiteSpace($msbuildExe) -or (-not (Test-Path $msbuildExe))) {
39+
throw "MSBuild.exe not found via vswhere. Please install Visual Studio Build Tools with MSBuild component."
40+
}
41+
42+
if ([string]::IsNullOrWhiteSpace($env:WIX)) {
43+
throw "WIX environment variable is not set. This project's PreBuildEvent uses $(WIX)bin\heat."
44+
}
45+
46+
& $msbuildExe $installerProject /t:Build /p:Configuration=Release /p:Platform=x86 /nologo
47+
if ($LASTEXITCODE -ne 0) {
48+
throw "Installer build failed: $installerProject"
49+
}
50+
51+
# Rename MSI to include git version
52+
$msiPath = Join-Path $scriptRoot "SecondaryClick.msi"
53+
if (Test-Path $msiPath) {
54+
Remove-Item "$scriptRoot\SecondaryClick-$version.msi" -ErrorAction SilentlyContinue
55+
Rename-Item $msiPath "SecondaryClick-$version.msi"
56+
}
57+
58+
# Build ZIP and 7Zip packages
2359
if (-not (Test-Path $sevenZip)) {
2460
throw "7z.exe file not found: $sevenZip"
2561
}
@@ -36,6 +72,8 @@ if (-not (Test-Path $releaseDir)) {
3672

3773
Remove-Item .\Package.7z -ErrorAction SilentlyContinue
3874
& $sevenZip a Package.7z "$releaseDir\*" -t7z -mx=9 -ms=on -m0=lzma2 -mf=BCJ2 -r -y
75+
76+
# Build EXE installer by MicaSetup
3977
& $makemicaPath micasetup.json
4078

4179
Compress-Archive "$releaseDir\*" SecondaryClick-$version.zip

build/rename-msi.ps1

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/SecondaryClick.Installer/SecondaryClick.Installer.wixproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<Error Text="The WiX Toolset v3.14 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
4040
</Target>
4141
<PropertyGroup>
42-
<PostBuildEvent>powershell -ExecutionPolicy Bypass -file "$(MSBuildThisFileDirectory)..\..\build\rename-msi.ps1"</PostBuildEvent>
42+
<PostBuildEvent></PostBuildEvent>
4343
</PropertyGroup>
4444
<PropertyGroup>
4545
<PreBuildEvent>if not exist "$(PackageDir)" (

0 commit comments

Comments
 (0)