-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathwindows_build.ps1
More file actions
86 lines (67 loc) · 2.68 KB
/
windows_build.ps1
File metadata and controls
86 lines (67 loc) · 2.68 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Build script for Windows Flutter application
# Usage: powershell -ExecutionPolicy Bypass -File .\windows_build.ps1
$ErrorActionPreference = "Stop"
# Configuration
$InnoCompiler = "C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
$InnoScriptName = "windows_setup.iss"
# Path configuration
$ProjectRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$VCLibsPath = "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Redist\MSVC\14.38.33130\x64\Microsoft.VC143.CRT"
$PubspecPath = Join-Path $ProjectRoot "client\pubspec.yaml"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Building Flutter Windows Application" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Read version from pubspec.yaml for Inno Setup
if (!(Test-Path $PubspecPath)) {
Write-Host "ERROR: pubspec.yaml not found at: $PubspecPath" -ForegroundColor Red
exit 1
}
$PubspecContent = Get-Content -Path $PubspecPath -Raw
$VersionMatch = [regex]::Match($PubspecContent, '(?m)^\s*version:\s*([^\s#]+)')
if (!$VersionMatch.Success) {
Write-Host "ERROR: Failed to parse version from pubspec.yaml" -ForegroundColor Red
exit 1
}
$AppVersion = $VersionMatch.Groups[1].Value.Trim()
$AppVersion = $AppVersion.Trim("'")
$AppVersion = $AppVersion.Trim('"')
Write-Host "Detected app version: $AppVersion" -ForegroundColor Green
Write-Host ""
# Build Flutter app
Write-Host "[1/2] Building Flutter Windows app (release)..." -ForegroundColor Yellow
$ClientPath = Join-Path $ProjectRoot "client"
Push-Location $ClientPath
try {
flutter build windows --release
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Flutter build failed!" -ForegroundColor Red
exit 1
}
Write-Host "Flutter build completed successfully." -ForegroundColor Green
} finally {
Pop-Location
}
Write-Host ""
Write-Host "[2/2] Creating installer with Inno Setup..." -ForegroundColor Yellow
# Compile Inno Setup script with path definitions
$InnoScript = Join-Path $ProjectRoot $InnoScriptName
# Pass path definitions to Inno Setup compiler
$InnoArgs = @(
"/DProjectRoot=$ProjectRoot"
"/DVCLibsPath=$VCLibsPath"
"/DMyAppVersion=$AppVersion"
$InnoScript
)
& $InnoCompiler @InnoArgs
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Inno Setup compilation failed!" -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Build completed successfully!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Installer created in: $ProjectRoot" -ForegroundColor Green
Write-Host ""