-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCOMPILAR_TODOS.bat
More file actions
293 lines (258 loc) · 9.65 KB
/
Copy pathCOMPILAR_TODOS.bat
File metadata and controls
293 lines (258 loc) · 9.65 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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
@echo off
setlocal EnableExtensions EnableDelayedExpansion
chcp 65001 >nul
rem =====================================================================
rem SystemInspector - Compilador dos utilitarios
rem
rem Projetos:
rem backup WindowsApp2\backup.vbproj .NET 4.8
rem restore restore\restoreapp.vbproj .NET 4.8
rem bootrepair bootrep\BootRepair.csproj .NET 8
rem partition partman\PartitionManager.csproj .NET 8
rem password pswrdreset\LocalPasswordReset.csproj .NET 8
rem smart smartdiskinfo\SmartHealthCheck.csproj .NET 8
rem sysfetch sysfetch\sysfetch.vbproj .NET 4.7.2
rem sysimplement sysimplement\sysimplement.csproj .NET 4.7.2
rem
rem Uso:
rem COMPILAR_TODOS.bat compila todos em Release
rem COMPILAR_TODOS.bat all compila todos em Release
rem COMPILAR_TODOS.bat clean limpa bin/obj/dist_tools
rem COMPILAR_TODOS.bat list mostra os nomes aceitos
rem COMPILAR_TODOS.bat backup compila apenas Backup Drivers
rem COMPILAR_TODOS.bat restore compila apenas Restore Drivers
rem COMPILAR_TODOS.bat bootrepair compila apenas Boot Repair
rem COMPILAR_TODOS.bat partition compila apenas Partition Manager
rem COMPILAR_TODOS.bat password compila apenas Local Password Reset
rem COMPILAR_TODOS.bat smart compila apenas SMART Health Check
rem COMPILAR_TODOS.bat sysfetch compila apenas SysFetch
rem COMPILAR_TODOS.bat sysimplement compila apenas SysImplement
rem =====================================================================
set "ROOT=%~dp0"
cd /d "%ROOT%"
set "ACTION=%~1"
if "%ACTION%"=="" set "ACTION=all"
if /I "%ACTION%"=="clean" goto :CLEAN
if /I "%ACTION%"=="list" goto :LIST
call :FIND_MSBUILD
if errorlevel 1 goto :ERROR
call :CHECK_DOTNET
if errorlevel 1 goto :ERROR
call :INSTALL_ALL_ICONS
if errorlevel 1 goto :ERROR
if /I "%ACTION%"=="all" goto :BUILD_ALL
if /I "%ACTION%"=="backup" goto :ONLY_BACKUP
if /I "%ACTION%"=="restore" goto :ONLY_RESTORE
if /I "%ACTION%"=="bootrepair" goto :ONLY_BOOT
if /I "%ACTION%"=="partition" goto :ONLY_PARTITION
if /I "%ACTION%"=="password" goto :ONLY_PASSWORD
if /I "%ACTION%"=="smart" goto :ONLY_SMART
if /I "%ACTION%"=="sysfetch" goto :ONLY_SYSFETCH
if /I "%ACTION%"=="sysimplement" goto :ONLY_SYSIMPLEMENT
echo ERRO: Projeto "%ACTION%" desconhecido.
goto :LIST
:BUILD_ALL
call :BUILD_FRAMEWORK "WindowsApp2\backup.vbproj" "BackupDrivers"
if errorlevel 1 goto :ERROR
call :BUILD_FRAMEWORK "restore\restoreapp.vbproj" "RestoreDrivers"
if errorlevel 1 goto :ERROR
call :BUILD_DOTNET "bootrep\BootRepair.csproj" "BootRepair"
if errorlevel 1 goto :ERROR
call :BUILD_DOTNET "partman\PartitionManager.csproj" "PartitionManager"
if errorlevel 1 goto :ERROR
call :BUILD_DOTNET "pswrdreset\LocalPasswordReset.csproj" "LocalPasswordReset"
if errorlevel 1 goto :ERROR
call :BUILD_DOTNET "smartdiskinfo\SmartHealthCheck.csproj" "SmartHealthCheck"
if errorlevel 1 goto :ERROR
call :BUILD_FRAMEWORK "sysfetch\sysfetch.vbproj" "SysFetch"
if errorlevel 1 goto :ERROR
call :BUILD_FRAMEWORK "sysimplement\sysimplement.csproj" "SysImplement"
if errorlevel 1 goto :ERROR
goto :SUCCESS
:ONLY_BACKUP
call :BUILD_FRAMEWORK "WindowsApp2\backup.vbproj" "BackupDrivers"
goto :CHECK_ONE
:ONLY_RESTORE
call :BUILD_FRAMEWORK "restore\restoreapp.vbproj" "RestoreDrivers"
goto :CHECK_ONE
:ONLY_BOOT
call :BUILD_DOTNET "bootrep\BootRepair.csproj" "BootRepair"
goto :CHECK_ONE
:ONLY_PARTITION
call :BUILD_DOTNET "partman\PartitionManager.csproj" "PartitionManager"
goto :CHECK_ONE
:ONLY_PASSWORD
call :BUILD_DOTNET "pswrdreset\LocalPasswordReset.csproj" "LocalPasswordReset"
goto :CHECK_ONE
:ONLY_SMART
call :BUILD_DOTNET "smartdiskinfo\SmartHealthCheck.csproj" "SmartHealthCheck"
goto :CHECK_ONE
:ONLY_SYSFETCH
call :BUILD_FRAMEWORK "sysfetch\sysfetch.vbproj" "SysFetch"
goto :CHECK_ONE
:ONLY_SYSIMPLEMENT
call :BUILD_FRAMEWORK "sysimplement\sysimplement.csproj" "SysImplement"
goto :CHECK_ONE
:CHECK_ONE
if errorlevel 1 goto :ERROR
goto :SUCCESS
: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/Build Tools com .NET desktop build tools.
exit /b 1
)
echo MSBuild: %MSBUILD%
exit /b 0
:CHECK_DOTNET
where dotnet >nul 2>&1
if errorlevel 1 (
echo ERRO: dotnet.exe nao encontrado. Os utilitarios .NET 8 precisam do .NET SDK 8.x.
exit /b 1
)
exit /b 0
:INSTALL_ALL_ICONS
if not exist "%ROOT%Icons" mkdir "%ROOT%Icons"
call :SET_ICON "WindowsApp2\backup.vbproj" "Icons\Backup.ico"
if errorlevel 1 exit /b 1
call :SET_ICON "restore\restoreapp.vbproj" "Icons\Restore.ico"
if errorlevel 1 exit /b 1
call :SET_ICON "bootrep\BootRepair.csproj" "Icons\BootRepair.ico"
if errorlevel 1 exit /b 1
call :SET_ICON "partman\PartitionManager.csproj" "Icons\PartitionManager.ico"
if errorlevel 1 exit /b 1
call :SET_ICON "pswrdreset\LocalPasswordReset.csproj" "Icons\LocalPasswordReset.ico"
if errorlevel 1 exit /b 1
call :SET_ICON "smartdiskinfo\SmartHealthCheck.csproj" "Icons\SmartHealthCheck.ico"
if errorlevel 1 exit /b 1
call :SET_ICON "sysfetch\sysfetch.vbproj" "Icons\SysFetch.ico"
if errorlevel 1 exit /b 1
call :SET_ICON "sysimplement\sysimplement.csproj" "Icons\SysImplement.ico"
if errorlevel 1 exit /b 1
exit /b 0
:SET_ICON
set "PROJREL=%~1"
set "ICONREL=%~2"
set "PROJ=%ROOT%%PROJREL%"
set "ICON=%ROOT%%ICONREL%"
if not exist "%PROJ%" (
echo ERRO: Projeto nao encontrado: %PROJREL%
exit /b 1
)
if not exist "%ICON%" (
echo ERRO: Icone nao encontrado: %ICONREL%
exit /b 1
)
for %%D in ("%PROJ%") do set "PROJDIR=%%~dpD"
copy /y "%ICON%" "%PROJDIR%AppIcon.ico" >nul
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
"$p='%PROJ%'; $x=[xml](Get-Content -LiteralPath $p);" ^
"$root=$x.DocumentElement;" ^
"$ns=$root.NamespaceURI;" ^
"if($ns){$mgr=New-Object Xml.XmlNamespaceManager($x.NameTable);$mgr.AddNamespace('m',$ns);$n=$x.SelectSingleNode('//m:ApplicationIcon',$mgr);$pg=$x.SelectSingleNode('/m:Project/m:PropertyGroup[1]',$mgr)}else{$n=$x.SelectSingleNode('//ApplicationIcon');$pg=$x.SelectSingleNode('/Project/PropertyGroup[1]')}" ^
"if(-not $n){$n=$x.CreateElement('ApplicationIcon',$ns);[void]$pg.AppendChild($n)};$n.InnerText='AppIcon.ico';$x.Save($p)"
if errorlevel 1 (
echo ERRO: Falha ao configurar icone de %PROJREL%.
exit /b 1
)
echo Icone: %PROJREL% ^<-- %ICONREL%
exit /b 0
:BUILD_FRAMEWORK
set "PROJECT=%ROOT%%~1"
set "NAME=%~2"
echo.
echo ================================================================
echo %NAME%
echo ================================================================
"%MSBUILD%" "%PROJECT%" /t:Restore,Rebuild /m /nologo /v:minimal /p:Configuration=Release /p:Platform=AnyCPU
if errorlevel 1 exit /b 1
call :PACKAGE_PROJECT "%PROJECT%" "%NAME%"
exit /b %ERRORLEVEL%
:BUILD_DOTNET
set "PROJECT=%ROOT%%~1"
set "NAME=%~2"
echo.
echo ================================================================
echo %NAME%
echo ================================================================
dotnet restore "%PROJECT%" --nologo
if errorlevel 1 exit /b 1
dotnet build "%PROJECT%" -c Release --no-restore --nologo
if errorlevel 1 exit /b 1
call :PACKAGE_PROJECT "%PROJECT%" "%NAME%"
exit /b %ERRORLEVEL%
:PACKAGE_PROJECT
set "PROJECT=%~1"
set "NAME=%~2"
set "DEST=%ROOT%dist_tools\%NAME%"
if exist "%DEST%" rmdir /s /q "%DEST%"
mkdir "%DEST%"
for %%D in ("%PROJECT%") do set "PDIR=%%~dpD"
set "FOUND_EXE="
for /f "delims=" %%F in ('dir /s /b /a-d "%PDIR%bin\Release\*.exe" 2^>nul') do (
echo %%F | findstr /i "\\ref\\ \\publish\\" >nul || (
if not defined FOUND_EXE set "FOUND_EXE=%%F"
)
)
if not defined FOUND_EXE (
echo ERRO: Nenhum EXE encontrado para %NAME%.
exit /b 1
)
for %%F in ("%FOUND_EXE%") do set "BINDIR=%%~dpF"
xcopy /e /i /y "%BINDIR%*" "%DEST%\" >nul
echo Distribuicao: dist_tools\%NAME%
exit /b 0
:LIST
echo.
echo Projetos disponiveis:
echo backup
echo restore
echo bootrepair
echo partition
echo password
echo smart
echo sysfetch
echo sysimplement
exit /b 0
:CLEAN
echo Limpando projetos auxiliares...
for %%D in (WindowsApp2 restore bootrep partman pswrdreset smartdiskinfo sysfetch sysimplement) do (
if exist "%ROOT%%%D\bin" rmdir /s /q "%ROOT%%%D\bin"
if exist "%ROOT%%%D\obj" rmdir /s /q "%ROOT%%%D\obj"
)
if exist "%ROOT%dist_tools" rmdir /s /q "%ROOT%dist_tools"
echo Limpeza concluida.
exit /b 0
:SUCCESS
echo.
echo ================================================================
echo COMPILACAO CONCLUIDA
echo ================================================================
echo.
echo Saida: %ROOT%dist_tools
explorer "%ROOT%dist_tools" >nul 2>&1
exit /b 0
:ERROR
set "RC=%ERRORLEVEL%"
echo.
echo ================================================================
echo COMPILACAO FALHOU - codigo %RC%
echo ================================================================
echo.
pause
exit /b %RC%