-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCOMPILAR.bat
More file actions
239 lines (202 loc) · 7.63 KB
/
Copy pathCOMPILAR.bat
File metadata and controls
239 lines (202 loc) · 7.63 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
@echo off
setlocal EnableExtensions EnableDelayedExpansion
chcp 65001 >nul
rem ================================================================
rem SystemInspector / DeviceMan - Compilador local
rem Requisitos:
rem - Visual Studio 2022/2026 ou Build Tools com .NET desktop build tools
rem - .NET Framework 4.8 Developer Pack
rem - Para modo ALL: .NET SDK 8.x
rem
rem Uso:
rem COMPILAR.bat -> Release do SystemInspector
rem COMPILAR.bat debug -> Debug do SystemInspector
rem COMPILAR.bat all -> Suite completa em Release
rem COMPILAR.bat clean -> Limpa bin/obj dos projetos
rem ================================================================
set "ROOT=%~dp0"
cd /d "%ROOT%"
set "MODE=%~1"
if /I "%MODE%"=="" set "MODE=release"
if /I "%MODE%"=="clean" goto :CLEAN
if /I "%MODE%"=="debug" (
set "CONFIG=Debug"
set "BUILD_ALL=0"
) else if /I "%MODE%"=="all" (
set "CONFIG=Release"
set "BUILD_ALL=1"
) else (
set "CONFIG=Release"
set "BUILD_ALL=0"
)
echo.
echo ================================================================
echo SystemInspector - Build %CONFIG%
echo ================================================================
echo.
call :FIND_MSBUILD
if errorlevel 1 goto :ERROR
call :INSTALL_ICON
if errorlevel 1 goto :ERROR
echo [1/4] Restaurando dependencias do projeto principal...
"%MSBUILD%" "%ROOT%WindowsApp1\Systeminspector.vbproj" /t:Restore /m /nologo /v:minimal /p:Configuration=%CONFIG% /p:Platform=AnyCPU
if errorlevel 1 goto :ERROR
echo.
echo [2/4] Compilando SystemInspector...
"%MSBUILD%" "%ROOT%WindowsApp1\Systeminspector.vbproj" /t:Rebuild /m /nologo /v:minimal /p:Configuration=%CONFIG% /p:Platform=AnyCPU
if errorlevel 1 goto :ERROR
if "%BUILD_ALL%"=="1" call :BUILD_SUITE
if errorlevel 1 goto :ERROR
echo.
echo [3/4] Preparando pasta de distribuicao...
call :PACKAGE
if errorlevel 1 goto :ERROR
echo.
echo [4/4] Concluido.
echo.
echo Executavel principal:
echo %ROOT%dist\SystemInspector\SystemInspector.exe
echo.
explorer "%ROOT%dist\SystemInspector" >nul 2>&1
exit /b 0
:FIND_MSBUILD
set "MSBUILD="
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if exist "%VSWHERE%" (
for /f "usebackq tokens=*" %%I in (`"%VSWHERE%" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do (
if not defined MSBUILD set "MSBUILD=%%I"
)
)
if not defined MSBUILD (
for %%P in (
"%ProgramFiles%\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"
"%ProgramFiles%\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe"
"%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe"
) do if exist "%%~P" if not defined MSBUILD set "MSBUILD=%%~P"
)
if not defined MSBUILD (
echo ERRO: MSBuild nao encontrado.
echo Instale Visual Studio ou Build Tools com o workload '.NET desktop build tools'.
exit /b 1
)
echo MSBuild: %MSBUILD%
exit /b 0
:INSTALL_ICON
set "ICON_SOURCE=%ROOT%SystemInspector.ico"
set "ICON_DEST=%ROOT%WindowsApp1\Resources\SystemInspector.ico"
if not exist "%ICON_SOURCE%" (
echo AVISO: SystemInspector.ico nao encontrado na raiz. Build continuara sem atualizar o icone.
exit /b 0
)
if not exist "%ROOT%WindowsApp1\Resources" mkdir "%ROOT%WindowsApp1\Resources"
copy /y "%ICON_SOURCE%" "%ICON_DEST%" >nul
rem Insere ApplicationIcon no VBPROJ somente se ainda nao estiver configurado.
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$p='%ROOT%WindowsApp1\Systeminspector.vbproj';" ^
"$x=[xml](Get-Content -LiteralPath $p);" ^
"$ns=New-Object System.Xml.XmlNamespaceManager($x.NameTable);$ns.AddNamespace('m','http://schemas.microsoft.com/developer/msbuild/2003');" ^
"$n=$x.SelectSingleNode('//m:ApplicationIcon',$ns);" ^
"if(-not $n){$pg=$x.SelectSingleNode('/m:Project/m:PropertyGroup[1]',$ns);$n=$x.CreateElement('ApplicationIcon',$x.DocumentElement.NamespaceURI);$n.InnerText='Resources\SystemInspector.ico';[void]$pg.AppendChild($n);$x.Save($p)}else{$n.InnerText='Resources\SystemInspector.ico';$x.Save($p)}"
if errorlevel 1 (
echo ERRO: Nao foi possivel configurar ApplicationIcon no projeto.
exit /b 1
)
echo Icone principal: WindowsApp1\Resources\SystemInspector.ico
exit /b 0
:BUILD_SUITE
echo.
echo ================================================================
echo Compilando modulos adicionais
echo ================================================================
rem Projetos .NET Framework auxiliares
for %%P in (
"sysfetch\sysfetch.vbproj"
"sysimplement\sysimplement.csproj"
) do (
if exist "%ROOT%%%~P" (
echo [MSBuild] %%~P
"%MSBUILD%" "%ROOT%%%~P" /t:Rebuild /m /nologo /v:minimal /p:Configuration=Release /p:Platform=AnyCPU
if errorlevel 1 exit /b 1
)
)
where dotnet >nul 2>&1
if errorlevel 1 (
echo ERRO: dotnet.exe nao encontrado. O modo ALL requer .NET SDK 8.x.
exit /b 1
)
for %%P in (
"bootrep\BootRepair.csproj"
"partman\PartitionManager.csproj"
"pswrdreset\LocalPasswordReset.csproj"
"smartdiskinfo\SmartHealthCheck.csproj"
) do (
if exist "%ROOT%%%~P" (
echo [dotnet] %%~P
dotnet build "%ROOT%%%~P" -c Release --nologo
if errorlevel 1 exit /b 1
)
)
exit /b 0
:PACKAGE
set "OUT=%ROOT%dist\SystemInspector"
if exist "%OUT%" rmdir /s /q "%OUT%"
mkdir "%OUT%"
set "BIN=%ROOT%WindowsApp1\bin\%CONFIG%"
if not exist "%BIN%\SystemInspector.exe" (
echo ERRO: SystemInspector.exe nao encontrado em "%BIN%".
exit /b 1
)
copy /y "%BIN%\SystemInspector.exe" "%OUT%\" >nul
if exist "%BIN%\SystemInspector.exe.config" copy /y "%BIN%\SystemInspector.exe.config" "%OUT%\" >nul
if exist "%BIN%\SystemInspector.xml" copy /y "%BIN%\SystemInspector.xml" "%OUT%\" >nul
for %%F in (
Aga.Controls.dll
OpenHardwareMonitorLib.dll
OpenHardwareMonitorLib.sys
OpenHardwareMonitor.exe
OxyPlot.dll
OxyPlot.WindowsForms.dll
) do if exist "%BIN%\%%F" copy /y "%BIN%\%%F" "%OUT%\" >nul
if exist "%ROOT%WindowsApp1\License.html" copy /y "%ROOT%WindowsApp1\License.html" "%OUT%\" >nul
if exist "%ROOT%LICENSE.txt" copy /y "%ROOT%LICENSE.txt" "%OUT%\" >nul
if exist "%ROOT%WindowsApp1\Languages" xcopy /e /i /y "%ROOT%WindowsApp1\Languages" "%OUT%\Languages" >nul
rem Copia dependencias geradas pelos ProjectReference quando existirem.
if exist "%BIN%\restoreapp.exe" copy /y "%BIN%\restoreapp.*" "%OUT%\" >nul 2>&1
if exist "%BIN%\WindowsApp2.exe" copy /y "%BIN%\WindowsApp2.*" "%OUT%\" >nul 2>&1
if "%BUILD_ALL%"=="1" (
if not exist "%OUT%\Tools" mkdir "%OUT%\Tools"
call :COPY_TOOL "bootrep\bin\Release" "BootRepair.exe"
call :COPY_TOOL "partman\bin\Release" "PartitionManager.exe"
call :COPY_TOOL "pswrdreset\bin\Release" "LocalPasswordReset.exe"
call :COPY_TOOL "smartdiskinfo\bin\Release" "SmartHealthCheck.exe"
call :COPY_TOOL "sysfetch\bin\Release" "sysfetch.exe"
call :COPY_TOOL "sysimplement\bin\Release" "sysimplement.exe"
)
exit /b 0
:COPY_TOOL
set "SEARCHDIR=%ROOT%%~1"
set "TOOLNAME=%~2"
for /r "%SEARCHDIR%" %%F in ("%TOOLNAME%") do (
if exist "%%~fF" (
copy /y "%%~fF" "%OUT%\Tools\" >nul
goto :eof
)
)
goto :eof
:CLEAN
echo Limpando bin e obj...
for /d /r "%ROOT%" %%D in (bin obj) do (
if exist "%%~fD" rmdir /s /q "%%~fD" 2>nul
)
if exist "%ROOT%dist" rmdir /s /q "%ROOT%dist"
echo Limpeza concluida.
exit /b 0
:ERROR
echo.
echo ================================================================
echo BUILD FALHOU - codigo %ERRORLEVEL%
echo ================================================================
echo.
pause
exit /b 1