-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
71 lines (59 loc) · 2.39 KB
/
build.bat
File metadata and controls
71 lines (59 loc) · 2.39 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
@echo off
setlocal EnableDelayedExpansion
:: Auto-elevate to Administrator
net session >nul 2>&1
if %errorLevel% neq 0 (
powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
exit /b
)
:: ANSI colors
for /f %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
set "GREEN=%ESC%[92m"
set "RED=%ESC%[91m"
set "YELLOW=%ESC%[93m"
set "CYAN=%ESC%[96m"
set "GRAY=%ESC%[90m"
set "RESET=%ESC%[0m"
cd /d "%~dp0"
:: Read version from .csproj
for /f "tokens=*" %%a in ('powershell -Command "(Select-String -Path GameRegionGuard.csproj -Pattern '<Version>(.*)</Version>').Matches.Groups[1].Value"') do set "VERSION=%%a"
:: Capture .NET SDK version
for /f %%a in ('dotnet --version 2^>nul') do set "SDKVER=%%a"
if "%SDKVER%"=="" (
echo.
echo %RED% [ERROR]%RESET% .NET SDK not found. Install it from https://dotnet.microsoft.com/download
echo.
echo %GRAY% Press any key to close...%RESET%
pause >nul
exit /b 1
)
:: Capture start time via PowerShell (avoids leading-space parsing issues)
for /f %%a in ('powershell -Command "[int](Get-Date).TimeOfDay.TotalSeconds"') do set "START=%%a"
echo.
echo %CYAN% [INFO]%RESET% GameRegionGuard v%VERSION%
echo %CYAN% [INFO]%RESET% .NET SDK %SDKVER%
echo %CYAN% [INFO]%RESET% Target: win-x64 ^| Release ^| Self-contained ^| Single file
echo.
echo %GRAY% [INFO] Running dotnet publish...%RESET%
echo.
dotnet publish GameRegionGuard.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=None -p:DebugSymbols=false
set "CODE=%errorLevel%"
:: Elapsed time
for /f %%a in ('powershell -Command "[int](Get-Date).TimeOfDay.TotalSeconds"') do set "END=%%a"
set /a "ELAPSED=END-START"
echo.
if %CODE% equ 0 (
echo %GREEN% [SUCCESS]%RESET% Build completed in %ELAPSED%s
echo %GREEN% [SUCCESS]%RESET% Output: bin\Release\GameRegionGuard\GameRegionGuard.exe
) else (
echo %RED% [ERROR]%RESET% Build failed with exit code %CODE%
echo.
echo %YELLOW% [WARNING]%RESET% If dotnet publish output is unclear, check the following:
echo %GRAY% - SDK version mismatch : dotnet --version%RESET%
echo %GRAY% - Missing dependencies : dotnet restore%RESET%
echo %GRAY% - .NET 8 SDK download : https://dotnet.microsoft.com/download%RESET%
)
echo.
echo %GRAY% Press any key to close...%RESET%
pause >nul
endlocal