-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.cmd
More file actions
125 lines (105 loc) · 3.62 KB
/
build.cmd
File metadata and controls
125 lines (105 loc) · 3.62 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
@echo off
call :init
if exist bin rd /s /q bin
set app1=ReplForms
call :pack %app1%
exit /b 0
:pack
rem %1 - app
if not exist %1 goto :eof
for %%i in (%1\*.csproj) do set prj=%%~dpnxi
rem Build matrix
rem 1 - Build an app with many dlls (default)
rem 2 - Build a single-file app when NET [Desktop] runtime required (my favorite)
rem 3 - Build a single-file app when no runtime required (NET embedded)
rem 4 - Build an app with many dlls for Linux
set option=2
rem call :bin %1 %option% %prj% net8.0 win-x86
rem call :bin %1 %option% %prj% net9.0 win-x86
rem call :bin %1 %option% %prj% net10.0 win-x86
rem call :bin %1 %option% %prj% net8.0 win-x64
rem call :bin %1 %option% %prj% net9.0 win-x64
call :bin %1 %option% %prj% net10.0 win-x64
rem Linux
set option=4
rem call :bin %1 %option% %prj% net8.0 linux-x64
rem call :bin %1 %option% %prj% net9.0 linux-x64
rem call :bin %1 %option% %prj% net10.0 linux-x64
call :version_txt %1 %prj% > bin\version.txt
set pack=%1-v%version%.zip
if exist %pack% del %pack%
echo === Pack %pack% ===
"C:\Program Files\7-Zip\7z.exe" a %pack% LICENSE *.md *.sln *.cmd bin\ Templates\
"C:\Program Files\7-Zip\7z.exe" a %pack% -r -x!.* -x!bin -x!obj -x!PublishProfiles -x!*.user %1\
if exist %store% copy /y %pack% %store%
goto :eof
:bin
rem %1 - app
rem %2 - option
rem %3 - project.csproj
rem %4 - net
rem %5 - x86/x64
set win=
rem for /f "tokens=3 delims=<>" %%t in ('findstr "<OutputType>" %3') do if /%%t/==/WinExe/ set win=-windows
findstr /C:".0-windows" %3
if %errorlevel% equ 0 (
set win=-windows
) else (
set win=
)
echo === Build %1 %4%win% %5 ===
rem win
if /%2/==/1/ dotnet publish %3 -o bin\%4.%5 -f %4%win% -r %5
if /%2/==/2/ dotnet publish %3 -o bin\%4.%5 -f %4%win% -r %5 -p:PublishSingleFile=true --no-self-contained
if /%2/==/3/ dotnet publish %3 -o bin\%4.%5 -f %4%win% -r %5 -p:PublishSingleFile=true
rem linux
if /%2/==/4/ dotnet publish %3 -o bin\%4.%5 -f %4 -r %5 --self-contained
rem win
rem if /%2/==/1/ del bin\%4.%5\appsettings.json
rem if /%2/==/2/ del bin\%4.%5\appsettings.json
rem if /%2/==/3/ del bin\%4.%5\appsettings.json
rem linux
rem if /%2/==/4/ del bin\%4.%5\*.config.json
if /%2/==/4/ ren bin\%4.%5\*.config.json appsettings.json
goto :eof
:init
for /f "tokens=3,3" %%a in ('reg query "hkcu\control panel\international" /v sshortdate') do set sfmt=%%a
for /f "tokens=3,3" %%a in ('reg query "hkcu\control panel\international" /v slongdate') do set lfmt=%%a
reg add "hkcu\control panel\international" /v sshortdate /t reg_sz /d yyyy-MM-dd /f >nul
reg add "hkcu\control panel\international" /v slongdate /t reg_sz /d yyyy-MM-dd /f >nul
set ymd=%date%
reg add "hkcu\control panel\international" /v sshortdate /t reg_sz /d %sfmt% /f >nul
reg add "hkcu\control panel\international" /v slongdate /t reg_sz /d %lfmt% /f >nul
set store=G:\BankApps\AppStore
goto :eof
:lower
rem %1 - Source
rem %2 - source
echo>%Temp%\%1
for /f %%f in ('dir /b/l %Temp%\%1') do set %2=%%f
del %Temp%\%1
goto :eof
:version_txt
rem %1 - app
rem %2 - project.csproj
for /f "tokens=3 delims=<>" %%v in ('findstr "<Version>" %2') do set version=%%v
for /f "tokens=3 delims=<>" %%v in ('findstr "<Description>" %2') do set description=%%v
for %%i in (.) do set repo=%%~nxi
call :lower %repo% repol
echo %1
echo %description%
echo.
echo Version: v%version%
echo Date: %ymd%
echo.
echo Requires SDK .NET to build
echo Requires .NET [Desktop] Runtime to run
echo Download from https://dotnet.microsoft.com/download
echo.
echo Run with '--version' to get the version
echo Run with '--help' to get the help
echo.
echo https://github.com/diev/%repo%
echo https://gitverse.ru/diev/%repo%
echo https://gitflic.ru/project/diev/%repol%
goto :eof