-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.bat
More file actions
122 lines (103 loc) · 4.09 KB
/
Copy pathbuild.bat
File metadata and controls
122 lines (103 loc) · 4.09 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
@echo off
REM ============================================
REM Battery Monitor - Build Script
REM Auto-detects newest BatteryMonitor_XX.Y.cs
REM Copies -> compiles -> renames exe -> cleans up
REM ============================================
echo ============================================
echo Battery Monitor - Build Script
echo ============================================
REM ---- STEP 1: Find the newest BatteryMonitor_XX.Y.cs ----
set NEWEST_SRC=
for /f "delims=" %%F in ('dir /b /o:n BatteryMonitor_*.cs 2^>nul') do (
set NEWEST_SRC=%%F
)
if "%NEWEST_SRC%"=="" (
echo ERROR: No BatteryMonitor_XX.Y.cs file found in this folder.
pause
exit /b 1
)
echo Found newest source: %NEWEST_SRC%
REM ---- Extract version string from filename ----
set VER=%NEWEST_SRC:BatteryMonitor_=%
set VER=%VER:.cs=%
echo Version: %VER%
REM ---- STEP 2: Copy to BatteryMonitor.cs ----
echo Copying %NEWEST_SRC% -> BatteryMonitor.cs ...
copy /y "%NEWEST_SRC%" BatteryMonitor.cs >nul
REM ---- STEP 3: Locate compiler ----
set CSC_2022_64=C:\Program Files\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\Roslyn\csc.exe
set CSC_2022_32=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\Roslyn\csc.exe
set CSC_COMMUNITY_64=C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Roslyn\csc.exe
set CSC_COMMUNITY_32=C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Roslyn\csc.exe
set CSC_FALLBACK=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe
set CSC=
if exist "%CSC_2022_64%" set CSC=%CSC_2022_64%
if exist "%CSC_2022_32%" set CSC=%CSC_2022_32%
if exist "%CSC_COMMUNITY_64%" set CSC=%CSC_COMMUNITY_64%
if exist "%CSC_COMMUNITY_32%" set CSC=%CSC_COMMUNITY_32%
if exist "%CSC_FALLBACK%" set CSC=%CSC_FALLBACK%
if "%CSC%"=="" (
echo ERROR: No C# compiler found!
del BatteryMonitor.cs >nul 2>&1
pause
exit /b 1
)
REM ---- Locate System.Speech.dll in GAC ----
set SPEECH_DLL=
if exist "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF\System.Speech.dll" (
set SPEECH_DLL=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF\System.Speech.dll
)
if "%SPEECH_DLL%"=="" if exist "C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\System.Speech.dll" (
set SPEECH_DLL=C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\System.Speech.dll
)
if "%SPEECH_DLL%"=="" (
for /f "delims=" %%P in ('dir /b /s "C:\Windows\assembly\GAC_MSIL\System.Speech\*\System.Speech.dll" 2^>nul') do (
set SPEECH_DLL=%%P
)
)
if "%SPEECH_DLL%"=="" (
echo ERROR: System.Speech.dll not found in GAC.
del BatteryMonitor.cs >nul 2>&1
pause
exit /b 1
)
echo Using System.Speech: %SPEECH_DLL%
REM ---- STEP 4: Compile ----
echo Compiling BatteryMonitor.cs ...
set ICON_PARAM=
if exist battery.ico (
set ICON_PARAM=/win32icon:battery.ico
echo Using icon: battery.ico
) else (
echo No battery.ico found - building without custom icon
)
set MANIFEST_PARAM=
if exist app.manifest (
set MANIFEST_PARAM=/win32manifest:app.manifest
echo Using manifest: app.manifest [requests Admin elevation + WMI access]
) else (
echo WARNING: app.manifest not found - battery temperature will not be available
)
"%CSC%" /target:winexe /out:BatteryMonitor.exe %ICON_PARAM% %MANIFEST_PARAM% /reference:System.dll /reference:System.Windows.Forms.dll /reference:System.Drawing.dll /reference:System.Management.dll /reference:"%SPEECH_DLL%" BatteryMonitor.cs
if %ERRORLEVEL% NEQ 0 (
echo ============================================
echo BUILD FAILED - check errors above
echo BatteryMonitor.cs kept for diagnostics
echo ============================================
pause
exit /b 1
)
REM ---- STEP 5: Rename exe ----
set EXE_OUT=BatteryMonitor_%VER%.exe
if exist "%EXE_OUT%" del "%EXE_OUT%" >nul
rename BatteryMonitor.exe "%EXE_OUT%"
echo Renamed to: %EXE_OUT%
REM ---- STEP 6: Cleanup ----
del BatteryMonitor.cs >nul
echo Cleaned up BatteryMonitor.cs
echo ============================================
echo BUILD SUCCESSFUL
echo Output: %EXE_OUT%
echo ============================================
pause