-
Notifications
You must be signed in to change notification settings - Fork 1
/
buildscript.bat
96 lines (87 loc) · 2.27 KB
/
buildscript.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
@SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
@ECHO OFF
REM Memorize master directory
SET "STARTDIR=%~dp0"
REM Disable telemetry data collection for M$
SET "DOTNET_CLI_TELEMETRY_OPTOUT=1"
ECHO.Root directory [%STARTDIR%]
REM Variable settings
SET "DESTPATH=build"
SET "DESTFRAM=netcoreapp3.1"
REM SET "DESTTYPE=Release"
SET "DESTTYPE=Debug"
SET "PLUGINPATH=Plugins"
SET "DELFILEEXT=json pdb"
SET "ARCHTYPES=win-x64 linux-x64 linux-arm"
REM Check commandline parameter for architecture
IF /i [%1] == [] (
REM Default architecture will be for Raspbian => Linux on ARM, 32-bit
SET "DESTARCH=linux-arm"
GOTO :START
)
REM Only defined types are supported
FOR %%i IN (%ARCHTYPES%) DO (
IF /i [%1] == [%%i] (
SET "DESTARCH=%%i"
GOTO :START
)
)
ECHO.Selected architecture [%1] not supported.
ECHO.Supported architectures are [%ARCHTYPES%].
GOTO :END
REM Append directory to variable
:APA
SET "TMPDIR=%~dpn1\\%~n2"
FOR /f %%F IN ("%TMPDIR%") DO SET "%3=%%~dpnF"
EXIT /B
REM Function DotNet Publish
:DNP
REM Check for plugin path
SET PATHINPUT=%~dpn1
CALL :APA %~dpn2 %DESTARCH% DEPLOYPATH
IF /i "%PATHINPUT:Plugins=%"=="%PATHINPUT%" (
SET "SELFCONTAINED=--self-contained"
) ELSE (
CALL :APA %DEPLOYPATH% %PLUGINPATH% DEPLOYPATH
SET "SELFCONTAINED="
)
REM If project file exists, publish it
IF EXIST "%1" (
ECHO.Publishing [%1] to [%DEPLOYPATH%]
CD %~dp1
dotnet publish -c %DESTTYPE% -f %DESTFRAM% %SELFCONTAINED% --force -o "%DEPLOYPATH%" -r %DESTARCH%
)
EXIT /B
REM Cleanup old version
:CLEANUP
CALL :APA %1 %DESTARCH% CLEANUPDIR
IF EXIST "%CLEANUPDIR%" (
ECHO.Cleaning up [%CLEANUPDIR%]
RMDIR /s /q "%CLEANUPDIR%"
)
EXIT /B
REM Remove obsolete files
:ROF
FOR %%i IN (%DELFILEEXT%) DO (
REM Search for file with given extension
FOR /r "%1" %%a IN (*.%%i) DO (
REM Delete file
DEL /f /q "%%a"
)
)
EXIT /B
REM For all projects in solution
:START
ECHO.Selected architecture [%DESTARCH%]
CD %STARTDIR%
CALL :APA %STARTDIR% %DESTPATH% DEPLOYBASE
CALL :CLEANUP %DEPLOYBASE%
FOR /f "delims=" %%f IN ('DIR /b /s /a-d *.csproj') DO (
REM Publish project
CALL :DNP "%%f" "%DEPLOYBASE%"
)
CD %STARTDIR%
REM CALL :ROF "%DEPLOYBASE%"
REM Switch back to startup directory
:END
CD %STARTDIR%