forked from nekopanda/Amatsukaze
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpublish.bat
More file actions
94 lines (82 loc) · 3.55 KB
/
publish.bat
File metadata and controls
94 lines (82 loc) · 3.55 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
@echo off
setlocal
where dotnet >nul 2>&1
if errorlevel 1 (
echo dotnet command not found. Install .NET 10 SDK.
exit /b 1
)
dotnet --list-sdks | findstr /R "^10\." >nul
if errorlevel 1 (
echo .NET 10 SDK not found. Check dotnet --list-sdks.
exit /b 1
)
if not exist ".\publish\win-x64" mkdir ".\publish\win-x64"
del .\publish\win-x64\*.dll >nul 2>&1
del .\publish\win-x64\*.dll.config >nul 2>&1
del .\publish\win-x64\*.exe >nul 2>&1
del .\publish\win-x64\*.pdb >nul 2>&1
set "VSWHERE="
for /f "usebackq delims=" %%I in (`where vswhere.exe 2^>nul`) do (
set "VSWHERE=%%~fI"
goto :vswhere_found
)
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if "%VSWHERE%"=="" if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" set "VSWHERE=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
if "%VSWHERE%"=="" if exist "%SystemDrive%\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" set "VSWHERE=%SystemDrive%\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
:vswhere_found
if "%VSWHERE%"=="" (
echo vswhere.exe not found in PATH or standard install directories.
exit /b 1
)
set "VSINSTALL="
set "VSTMP=%TEMP%\amatsukaze_vsinstall.txt"
"%VSWHERE%" -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath > "%VSTMP%"
if errorlevel 1 (
echo vswhere.exe failed.
if exist "%VSTMP%" del /q "%VSTMP%" >nul 2>&1
exit /b 1
)
if exist "%VSTMP%" set /p VSINSTALL=<"%VSTMP%"
if exist "%VSTMP%" del /q "%VSTMP%" >nul 2>&1
if "%VSINSTALL%"=="" (
echo Visual Studio with VC++ tools not found.
exit /b 1
)
set "VCVARS=%VSINSTALL%\VC\Auxiliary\Build\vcvars64.bat"
set "MSBUILD=%VSINSTALL%\MSBuild\Current\Bin\MSBuild.exe"
if not exist "%VCVARS%" (
echo vcvars64.bat not found: %VCVARS%
exit /b 1
)
if not exist "%MSBUILD%" (
echo MSBuild.exe not found: %MSBUILD%
exit /b 1
)
echo Using Visual Studio: %VSINSTALL%
echo Using MSBuild: %MSBUILD%
call "%VCVARS%" x64
if errorlevel 1 exit /b %ERRORLEVEL%
echo Building solution with MSBuild (Release + Release2)...
"%MSBUILD%" Amatsukaze.sln /restore /p:Configuration=Release /p:Platform=x64 /m
if errorlevel 1 exit /b %ERRORLEVEL%
"%MSBUILD%" Amatsukaze.sln /p:Configuration=Release2 /p:Platform=x64 /m
if errorlevel 1 exit /b %ERRORLEVEL%
echo Publishing .NET projects in parallel via Publish.proj...
"%MSBUILD%" Publish.proj /m
if errorlevel 1 exit /b %ERRORLEVEL%
echo Collecting published artifacts into a single folder...
set MERGED_DIR=.\publish\win-x64
set SRC_BASE=.\publish\win-x64
rem robocopy returns codes <8 for success; treat >=8 as failure
if exist "%SRC_BASE%\AmatsukazeAddTask" robocopy "%SRC_BASE%\AmatsukazeAddTask" "%MERGED_DIR%" /E /NFL /NDL /NJH /NJS
if errorlevel 8 exit /b %ERRORLEVEL%
if exist "%SRC_BASE%\AmatsukazeServerCLI" robocopy "%SRC_BASE%\AmatsukazeServerCLI" "%MERGED_DIR%" /E /NFL /NDL /NJH /NJS
if errorlevel 8 exit /b %ERRORLEVEL%
if exist "%SRC_BASE%\AmatsukazeGUI" robocopy "%SRC_BASE%\AmatsukazeGUI" "%MERGED_DIR%" /E /NFL /NDL /NJH /NJS
if errorlevel 8 exit /b %ERRORLEVEL%
if exist "%SRC_BASE%\ScriptCommand" robocopy "%SRC_BASE%\ScriptCommand" "%MERGED_DIR%" /E /NFL /NDL /NJH /NJS
if errorlevel 8 exit /b %ERRORLEVEL%
if exist "%SRC_BASE%\AmatsukazeServer\wwwroot" robocopy "%SRC_BASE%\AmatsukazeServer\wwwroot" "%MERGED_DIR%\wwwroot" /E /NFL /NDL /NJH /NJS
if errorlevel 8 exit /b %ERRORLEVEL%
echo Done. Merged outputs are in %MERGED_DIR% (WebUI is served on REST port+1).
exit /b 0