1010Write-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
2359if (-not (Test-Path $sevenZip )) {
2460 throw " 7z.exe file not found: $sevenZip "
2561}
@@ -36,6 +72,8 @@ if (-not (Test-Path $releaseDir)) {
3672
3773Remove-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
4179Compress-Archive " $releaseDir \*" SecondaryClick- $version.zip
0 commit comments