-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
264 lines (234 loc) · 7.17 KB
/
build.bat
File metadata and controls
264 lines (234 loc) · 7.17 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
@echo off
setlocal enabledelayedexpansion
:: ------------------------------------------------------------
:: PSO2 Autonomous Server Build Script - FULLY DEBUGGED
:: ------------------------------------------------------------
:: Initialize ALL variables at start
set "BUILD_CONFIG="
set "VERBOSE_MODE="
set "OUTPUT_TO_FILE="
set "LOG_FILE=build_log.txt"
set "OUTDIR="
set "EXE_COUNT=0"
set "SUCCESS_COUNT=0"
set "EXECUTABLES=PSO2.Server.Main PSO2.AI.Engine PSO2.CodeGenerator PSO2.HotReload PSO2.ReverseEngineering PSO2.Training"
:: Create timestamp
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
for /f "tokens=1-3 delims=: " %%a in ("%time%") do (
set "TIMESTAMP=%%l-%%j-%%k_%%a-%%b-%%c"
)
)
set "TIMESTAMP=!TIMESTAMP: =0!"
:: Configuration prompts
cls
echo ================================================================
echo PSO2 Autonomous Server Build Configuration
echo ================================================================
echo.
:config_loop
echo Select build configuration:
echo 1. Debug
echo 2. Release
set /p "choice=Choice [1-2]: "
if "!choice!"=="1" set "BUILD_CONFIG=Debug" & goto verbose_loop
if "!choice!"=="2" set "BUILD_CONFIG=Release" & goto verbose_loop
echo Invalid choice. Try again.
goto config_loop
:verbose_loop
echo.
echo Enable verbose output?
echo 1. Yes
echo 2. No
set /p "choice=Choice [1-2]: "
if "!choice!"=="1" set "VERBOSE_MODE=true" & goto log_loop
if "!choice!"=="2" set "VERBOSE_MODE=false" & goto log_loop
echo Invalid choice. Try again.
goto verbose_loop
:log_loop
echo.
echo Save to log file?
echo 1. Yes
echo 2. No
set /p "choice=Choice [1-2]: "
if "!choice!"=="1" set "OUTPUT_TO_FILE=true" & goto start_build
if "!choice!"=="2" set "OUTPUT_TO_FILE=false" & goto start_build
echo Invalid choice. Try again.
goto log_loop
:start_build
:: Set log file with timestamp
if "!OUTPUT_TO_FILE!"=="true" (
set "LOG_FILE=build_log_!TIMESTAMP!.txt"
echo PSO2 Build Log - !BUILD_CONFIG! > "!LOG_FILE!"
echo Started: %date% %time% >> "!LOG_FILE!"
echo. >> "!LOG_FILE!"
)
cls
echo ================================================================
echo Starting PSO2 Build Process
echo Configuration: !BUILD_CONFIG!
echo Verbose: !VERBOSE_MODE!
echo Logging: !OUTPUT_TO_FILE!
echo ================================================================
:: Step 1: Environment Check
echo.
echo [1/8] Checking environment...
call :log "Checking .NET SDK..."
dotnet --version >temp_version.txt 2>&1
if !errorlevel! neq 0 (
call :log "ERROR: .NET SDK not found"
del temp_version.txt 2>nul
goto failure
)
set /p dotnet_version=<temp_version.txt
call :log "Found .NET SDK: !dotnet_version!"
del temp_version.txt
call :log "Current directory: %CD%"
:: Step 2: Check project structure
echo.
echo [2/8] Checking project structure...
call :log "Checking for solution file..."
if not exist "AutonomousPSO2Server.sln" (
call :log "ERROR: AutonomousPSO2Server.sln not found"
call :log "Available .sln files:"
for %%f in (*.sln) do call :log " - %%f"
call :log "No solution files found"
goto failure
)
call :log "Solution file found: AutonomousPSO2Server.sln"
call :log "Checking for src directory..."
if not exist "src" (
call :log "ERROR: src directory not found"
goto failure
)
call :log "src directory found"
call :log "Checking for project files..."
set "PROJECT_COUNT=0"
for %%P in (!EXECUTABLES!) do (
if exist "src\%%P\%%P.csproj" (
call :log " Found: src\%%P\%%P.csproj"
set /a PROJECT_COUNT+=1
) else (
call :log " Missing: src\%%P\%%P.csproj"
)
)
call :log "Found !PROJECT_COUNT! project files"
if !PROJECT_COUNT! equ 0 (
call :log "ERROR: No project files found"
goto failure
)
:: Step 3: Clean
echo.
echo [3/8] Cleaning previous build...
call :log "Running: dotnet clean"
dotnet clean AutonomousPSO2Server.sln --configuration !BUILD_CONFIG! --verbosity quiet
call :log "Clean completed"
:: Step 4: Restore
echo.
echo [4/8] Restoring packages...
call :log "Running: dotnet restore"
if "!VERBOSE_MODE!"=="true" (
dotnet restore AutonomousPSO2Server.sln --verbosity detailed
) else (
dotnet restore AutonomousPSO2Server.sln --verbosity minimal
)
if !errorlevel! neq 0 (
call :log "ERROR: Package restore failed"
goto failure
)
call :log "Packages restored successfully"
:: Step 5: Build
echo.
echo [5/8] Building solution...
call :log "Running: dotnet build !BUILD_CONFIG!"
if "!VERBOSE_MODE!"=="true" (
dotnet build AutonomousPSO2Server.sln --configuration !BUILD_CONFIG! --no-restore --verbosity detailed
) else (
dotnet build AutonomousPSO2Server.sln --configuration !BUILD_CONFIG! --no-restore --verbosity normal
)
if !errorlevel! neq 0 (
call :log "ERROR: Build failed"
goto failure
)
call :log "Build completed successfully"
:: Step 6: Prepare output
echo.
echo [6/8] Preparing output directory...
set "OUTDIR=bin\!BUILD_CONFIG!"
call :log "Output directory: !OUTDIR!"
if not exist "!OUTDIR!" mkdir "!OUTDIR!"
:: Step 7: Copy files
echo.
echo [7/8] Copying executables...
set "SUCCESS_COUNT=0"
set "EXE_COUNT=6"
for %%E in (!EXECUTABLES!) do (
set "SOURCE=src\%%E\bin\!BUILD_CONFIG!\net8.0\%%E.exe"
set "TARGET=!OUTDIR!\%%E.exe"
if exist "!SOURCE!" (
copy /Y "!SOURCE!" "!TARGET!" >nul 2>&1
if !errorlevel! equ 0 (
call :log " Copied: %%E.exe"
set /a SUCCESS_COUNT+=1
) else (
call :log " Failed to copy: %%E.exe"
)
) else (
call :log " Not found: !SOURCE!"
)
)
call :log "Copied !SUCCESS_COUNT! of !EXE_COUNT! executables"
:: Step 8: Finalize
echo.
echo [8/8] Finalizing build...
:: Create directories
for %%D in (config models templates handlers logs training_data) do (
if not exist "!OUTDIR!\%%D" mkdir "!OUTDIR!\%%D!"
echo # Created by build script > "!OUTDIR!\%%D\.gitkeep"
)
:: Create startup script
(
echo @echo off
echo echo Starting PSO2 Services...
for %%E in (!EXECUTABLES!) do (
echo if exist "%%E.exe" start "%%E" "%%E.exe"
)
echo pause
) > "!OUTDIR!\start_server.bat"
:: Build summary
if !SUCCESS_COUNT! gtr 0 (
goto success
) else (
call :log "ERROR: No executables were successfully copied"
goto failure
)
:success
echo.
echo ================================================================
echo BUILD SUCCESSFUL!
echo ================================================================
echo Configuration: !BUILD_CONFIG!
echo Output: !OUTDIR!
echo Files: !SUCCESS_COUNT!/!EXE_COUNT!
echo ================================================================
call :log "Build completed successfully"
if "!OUTPUT_TO_FILE!"=="true" call :log "Log saved: !LOG_FILE!"
echo Press any key to exit...
pause >nul
exit /b 0
:failure
echo.
echo ================================================================
echo BUILD FAILED!
echo ================================================================
echo Check the messages above for details
echo ================================================================
call :log "Build failed"
if "!OUTPUT_TO_FILE!"=="true" call :log "Error log saved: !LOG_FILE!"
echo Press any key to exit...
pause >nul
exit /b 1
:: Logging function
:log
echo %~1
if "!OUTPUT_TO_FILE!"=="true" echo [%time%] %~1 >> "!LOG_FILE!"
exit /b