-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathBuildLinuxPackages.bat
107 lines (93 loc) · 3.08 KB
/
BuildLinuxPackages.bat
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
@echo off
set APP_NAME=ULogViewer
set RID_LIST=linux-arm64 linux-x64
set CONFIG=Release
set FRAMEWORK=net9.0
set SELF_CONTAINED=true
set TRIM_ASSEMBLIES=true
set TESTING_MODE_BUILD=false
set PACKAGING_TOOL_PATH=PackagingTool\bin\Release\%FRAMEWORK%\CarinaStudio.ULogViewer.Packaging.dll
set ERRORLEVEL=0
echo ********** Start building %APP_NAME% **********
REM Create base directory
IF not exist Packages (
echo Create directory 'Packages'
mkdir Packages
if %ERRORLEVEL% neq 0 (
exit
)
)
REM Build packaging tool
dotnet build PackagingTool -c Release -f %FRAMEWORK%
if %ERRORLEVEL% neq 0 (
exit
)
REM Get current version
dotnet %PACKAGING_TOOL_PATH% get-current-version %APP_NAME%\%APP_NAME%.csproj > Packages\Packaging.txt
if %ERRORLEVEL% neq 0 (
del /Q Packages\Packaging.txt
exit
)
set /p CURRENT_VERSION=<Packages\Packaging.txt
echo Version: %CURRENT_VERSION%
REM Get previous version
dotnet %PACKAGING_TOOL_PATH% get-previous-version %APP_NAME%\%APP_NAME%.csproj > Packages\Packaging.txt
if %ERRORLEVEL% neq 0 (
del /Q Packages\Packaging.txt
exit
)
set /p PREVIOUS_VERSION=<Packages\Packaging.txt
if [%PREVIOUS_VERSION%] neq [] (
echo Previous version: %PREVIOUS_VERSION%
)
REM Create output directory
if not exist Packages\%CURRENT_VERSION% (
echo Create directory 'Packages\%CURRENT_VERSION%'
mkdir Packages\%CURRENT_VERSION%
)
REM Build packages
(for %%r in (%RID_LIST%) do (
REM Start building slf-contained package
echo .
echo [%%r]
echo .
REM Clear project
if exist %APP_NAME%\bin\%CONFIG%\%FRAMEWORK%\%%r\publish\ (
echo Delete output directory '%APP_NAME%\bin\%CONFIG%\%FRAMEWORK%\%%r\publish'
rmdir %APP_NAME%\bin\%CONFIG%\%FRAMEWORK%\%%r\publish /s /q
)
dotnet restore %APP_NAME% -r %%r
if %ERRORLEVEL% neq 0 (
echo Failed to restore project: %ERRORLEVEL%
del /Q Packages\Packaging.txt
exit
)
dotnet clean %APP_NAME% -c %CONFIG% -r %%r
if %ERRORLEVEL% neq 0 (
echo Failed to clean project: %ERRORLEVEL%
del /Q Packages\Packaging.txt
exit
)
REM Build project
dotnet publish %APP_NAME% -c %CONFIG% -r %%r --self-contained %SELF_CONTAINED% -p:PublishTrimmed=%TRIM_ASSEMBLIES% -p:TestingModeBuild=%TESTING_MODE_BUILD%
if %ERRORLEVEL% neq 0 (
echo Failed to build project: %ERRORLEVEL%
del /Q Packages\Packaging.txt
exit
)
REM Generate package
start /Wait PowerShell -NoLogo -Command Compress-Archive -Force -Path %APP_NAME%\bin\%CONFIG%\%FRAMEWORK%\%%r\publish\* -DestinationPath Packages\%CURRENT_VERSION%\%APP_NAME%-%CURRENT_VERSION%-%%r.zip
if %ERRORLEVEL% neq 0 (
echo Failed to generate package: %ERRORLEVEL%
del /Q Packages\Packaging.txt
exit
)
))
REM Generate diff packages
if [%PREVIOUS_VERSION%] neq [] (
dotnet %PACKAGING_TOOL_PATH% create-diff-packages linux %PREVIOUS_VERSION% %CURRENT_VERSION%
)
REM Generate package manifest
REM dotnet %PACKAGING_TOOL_PATH% create-package-manifest linux %APP_NAME% %CURRENT_VERSION%
REM Complete
del /Q Packages\Packaging.txt