-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMake.bat
More file actions
223 lines (185 loc) · 7.99 KB
/
Make.bat
File metadata and controls
223 lines (185 loc) · 7.99 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
@echo off
setlocal enabledelayedexpansion
REM Usage:
REM Make.bat [version] Release publish + installers (full clean first)
REM Make.bat -clean Clean workspace only (same as legacy Clean.bat)
REM Make.bat -c Alias for -clean
REM Make.bat -d [version] Debug publish to Build\Debug (no full clean)
set ERROR_COUNT=0
set BUILD_DIR=Build
set BUILD_ONLINE_DIR=Build-English
set RELEASE_ASSET_DIR=release-assets
set PAGES_ASSET_DIR=%RELEASE_ASSET_DIR%\pages
IF /I "%1"=="-clean" GOTO CLEAN_ONLY
IF /I "%1"=="-c" GOTO CLEAN_ONLY
IF "%1"=="-d" GOTO BUILD_DEBUG
IF "%1"=="" (
CALL :RESOLVE_VERSION
) ELSE (
SET VERSION=%1
)
IF "%VERSION%"=="" (
echo Failed to resolve version.
exit /b 1
)
SET PATH=%PATH%;"C:\Program Files (x86)\Inno Setup 6"
CALL :CLEAN_WORKSPACE
IF %ERROR_COUNT% NEQ 0 GOTO END
CALL :VALIDATE_MAIN_WINDOW_XAML
IF %ERROR_COUNT% NEQ 0 GOTO END
dotnet publish UniversalDeviceToolkit.WPF\UniversalDeviceToolkit.WPF.csproj -c release -o "%BUILD_DIR%" /p:DebugType=None /p:FileVersion=%VERSION% /p:Version=%VERSION%
IF %ERRORLEVEL% NEQ 0 set ERROR_COUNT=1
dotnet publish UniversalDeviceToolkit.CLI\UniversalDeviceToolkit.CLI.csproj -c release -o "%BUILD_DIR%" /p:DebugType=None /p:FileVersion=%VERSION% /p:Version=%VERSION%
IF %ERRORLEVEL% NEQ 0 set ERROR_COUNT=1
IF %ERROR_COUNT% NEQ 0 GOTO END
CALL :PRUNE_RELEASE_OUTPUT "%BUILD_DIR%"
powershell -NoProfile -ExecutionPolicy Bypass -File "Scripts\Build-LanguageAssets.ps1" -BuildDir "%BUILD_DIR%" -OnlineBuildDir "%BUILD_ONLINE_DIR%" -ReleaseOutput "%RELEASE_ASSET_DIR%" -PagesOutput "%PAGES_ASSET_DIR%" -Version "%VERSION%"
IF %ERRORLEVEL% NEQ 0 (
echo Release asset preparation failed.
set ERROR_COUNT=1
)
iscc MakeInstaller.iss /DMyAppVersion=%VERSION% /DMyAppSourceDir="%BUILD_DIR%" /DMyAppOutputBaseFilename=UniversalDeviceToolkitSetup-Full
IF %ERRORLEVEL% NEQ 0 (
echo Inno Setup failed for full installer.
set ERROR_COUNT=1
)
iscc MakeInstaller.iss /DMyAppVersion=%VERSION% /DMyAppSourceDir="%BUILD_ONLINE_DIR%" /DMyAppOutputBaseFilename=UniversalDeviceToolkitSetup-Online
IF %ERRORLEVEL% NEQ 0 (
echo Inno Setup failed for online installer.
set ERROR_COUNT=1
)
powershell -NoProfile -ExecutionPolicy Bypass -File "Scripts\Build-LanguageAssets.ps1" -FinalizeOnly -ReleaseOutput "%RELEASE_ASSET_DIR%" -PagesOutput "%PAGES_ASSET_DIR%" -Version "%VERSION%" -FullInstallerPath "BuildInstaller\UniversalDeviceToolkitSetup-Full.exe" -OnlineInstallerPath "BuildInstaller\UniversalDeviceToolkitSetup-Online.exe"
IF %ERRORLEVEL% NEQ 0 (
echo Release asset finalization failed.
set ERROR_COUNT=1
)
GOTO END
:CLEAN_ONLY
CALL :CLEAN_WORKSPACE
GOTO END
:BUILD_DEBUG
echo Building DEBUG version...
IF "%2"=="" (
CALL :RESOLVE_VERSION
) ELSE (
SET VERSION=%2
)
IF "%VERSION%"=="" (
echo Failed to resolve version.
exit /b 1
)
echo.
echo Building WPF Application (Debug)...
dotnet publish UniversalDeviceToolkit.WPF\UniversalDeviceToolkit.WPF.csproj -c Debug -o Build\Debug /p:FileVersion=%VERSION% /p:Version=%VERSION%
IF %ERRORLEVEL% NEQ 0 set ERROR_COUNT=1
echo.
echo Building Spectrum Tester (Debug)...
dotnet publish UniversalDeviceToolkit.SpectrumTester\UniversalDeviceToolkit.SpectrumTester.csproj -c Debug -o Build\Debug /p:FileVersion=%VERSION% /p:Version=%VERSION%
IF %ERRORLEVEL% NEQ 0 set ERROR_COUNT=1
echo.
echo Building CLI (Debug)...
dotnet publish UniversalDeviceToolkit.CLI\UniversalDeviceToolkit.CLI.csproj -c Debug -o Build\Debug /p:FileVersion=%VERSION% /p:Version=%VERSION%
IF %ERRORLEVEL% NEQ 0 set ERROR_COUNT=1
echo.
IF %ERROR_COUNT% EQU 0 (
echo Debug build completed successfully!
) ELSE (
echo Debug build completed with errors!
)
echo Output directory: Build\Debug
echo.
echo To debug: Open solution in VS 2022 and attach to process
echo.
GOTO END
:CLEAN_WORKSPACE
echo Cleaning workspace...
if exist ".vs" rmdir /s /q ".vs"
if exist "_ReSharper.Caches" rmdir /s /q "_ReSharper.Caches"
if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%"
if exist "%BUILD_ONLINE_DIR%" rmdir /s /q "%BUILD_ONLINE_DIR%"
if exist "BuildInstaller" rmdir /s /q "BuildInstaller"
if exist "%RELEASE_ASSET_DIR%" rmdir /s /q "%RELEASE_ASSET_DIR%"
if exist "%PAGES_ASSET_DIR%" rmdir /s /q "%PAGES_ASSET_DIR%"
for %%p in (
UniversalDeviceToolkit.CLI
UniversalDeviceToolkit.CLI.Lib
UniversalDeviceToolkit.Lib
UniversalDeviceToolkit.Lib.Automation
UniversalDeviceToolkit.Lib.Macro
UniversalDeviceToolkit.Lib.Plugins
UniversalDeviceToolkit.WPF
UniversalDeviceToolkit.SpectrumTester
UniversalDeviceToolkit.PerformanceTest
UniversalDeviceToolkit.Tests
) do (
if exist "%%p\bin" rmdir /s /q "%%p\bin"
if exist "%%p\obj" rmdir /s /q "%%p\obj"
)
if exist "UniversalDeviceToolkit.sln" (
dotnet clean UniversalDeviceToolkit.sln -v q
IF %ERRORLEVEL% NEQ 0 set ERROR_COUNT=1
)
exit /b 0
:VALIDATE_MAIN_WINDOW_XAML
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$xamlPath = 'UniversalDeviceToolkit.WPF\Windows\MainWindow.xaml';" ^
"$csPath = 'UniversalDeviceToolkit.WPF\Windows\MainWindow.xaml.cs';" ^
"if (-not (Test-Path $xamlPath)) { Write-Error 'Missing MainWindow.xaml'; exit 1 };" ^
"if (-not (Test-Path $csPath)) { Write-Error 'Missing MainWindow.xaml.cs'; exit 1 };" ^
"$xaml = Get-Content -Raw $xamlPath;" ^
"$cs = Get-Content -Raw $csPath;" ^
"if ($xaml -match 'MouseLeftButtonDown\s*=\s*\"UpdateIndicator_Click\"' -or $xaml -match 'MouseRightButtonDown\s*=\s*\"UpdateIndicator_Click\"') {" ^
" Write-Error 'MainWindow.xaml still binds UpdateIndicator_Click to mouse events. Remove those XAML bindings and wire mouse handlers in MainWindow.xaml.cs.'; exit 1 };" ^
"if ($cs -match 'UpdateIndicator_Click\(object sender,\s*RoutedEventArgs') {" ^
" Write-Error 'UpdateIndicator_Click must use MouseButtonEventArgs when handling mouse input.'; exit 1 };" ^
"exit 0"
IF %ERRORLEVEL% NEQ 0 (
echo MainWindow update-banner validation failed.
set ERROR_COUNT=1
)
exit /b 0
:PRUNE_RELEASE_OUTPUT
set TARGET_DIR=%~1
if "%TARGET_DIR%"=="" exit /b 0
if exist "%TARGET_DIR%\x86" rmdir /s /q "%TARGET_DIR%\x86"
if exist "%TARGET_DIR%\arm64" rmdir /s /q "%TARGET_DIR%\arm64"
if exist "%TARGET_DIR%\SpectrumTester.exe" del /q "%TARGET_DIR%\SpectrumTester.exe"
if exist "%TARGET_DIR%\SpectrumTester.dll" del /q "%TARGET_DIR%\SpectrumTester.dll"
if exist "%TARGET_DIR%\SpectrumTester.deps.json" del /q "%TARGET_DIR%\SpectrumTester.deps.json"
if exist "%TARGET_DIR%\SpectrumTester.runtimeconfig.json" del /q "%TARGET_DIR%\SpectrumTester.runtimeconfig.json"
exit /b 0
:END
echo.
IF "%1"=="-clean" (
IF %ERROR_COUNT% EQU 0 (
echo Clean completed!
) ELSE (
echo Clean completed with errors!
)
) ELSE IF /I "%1"=="-c" (
IF %ERROR_COUNT% EQU 0 (
echo Clean completed!
) ELSE (
echo Clean completed with errors!
)
) ELSE IF "%1"=="-d" (
IF %ERROR_COUNT% EQU 0 (
echo Debug build completed! Exiting in 5 seconds...
) ELSE (
echo Debug build completed with errors! Exiting in 5 seconds...
)
) ELSE (
IF %ERROR_COUNT% EQU 0 (
echo Build completed! Exiting in 5 seconds...
) ELSE (
echo Build completed with errors! Exiting in 5 seconds...
)
)
ping -n 6 127.0.0.1 >nul 2>&1
endlocal & exit /b %ERROR_COUNT%
:RESOLVE_VERSION
REM MajorVersion, MinorVersion, PatchVersion are plain numeric text nodes.
REM Reading them directly avoids the '$(�' MSBuild-expression interpolation
REM trap that causes NuGet to see '..' as a version string on some runners.
for /f "usebackq delims=" %%v in (`powershell -NoProfile -ExecutionPolicy Bypass -Command "$props=[xml](Get-Content -Raw 'Directory.Build.props'); $group=$props.Project.PropertyGroup | Where-Object { $_.MajorVersion -ne $null } | Select-Object -First 1; $maj=[string]$group.MajorVersion; $min=[string]$group.MinorVersion; $pat=[string]$group.PatchVersion; if ([string]::IsNullOrWhiteSpace($maj) -or [string]::IsNullOrWhiteSpace($min) -or [string]::IsNullOrWhiteSpace($pat)) { exit 1 }; '{0}.{1}.{2}' -f $maj,$min,$pat"`) do SET VERSION=%%v
exit /b %ERRORLEVEL%