-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpublish.bat
More file actions
164 lines (136 loc) · 2.94 KB
/
publish.bat
File metadata and controls
164 lines (136 loc) · 2.94 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
@echo off
setlocal EnableExtensions EnableDelayedExpansion
set "SCRIPT_DIR=%~dp0"
set "PROJECT_PATH=%SCRIPT_DIR%optimizerDuck\optimizerDuck.csproj"
set "TEST_PROJECT=%SCRIPT_DIR%optimizerDuck.Test\optimizerDuck.Test.csproj"
set "CONFIGURATION=Release"
set "PROFILE="
set "RUN_TESTS=1"
set "PAUSE_ON_EXIT=1"
call :parse_args %*
if errorlevel 1 goto :fail
pushd "%SCRIPT_DIR%" >nul || (
echo Failed to open repository root.
goto :fail
)
call :ensure_dotnet || goto :cleanup_fail
if not exist "%PROJECT_PATH%" (
echo Project file not found: "%PROJECT_PATH%"
goto :cleanup_fail
)
if not defined PROFILE call :choose_profile
if not defined PROFILE goto :cleanup_fail
echo.
echo ========================================
echo optimizerDuck publish
echo ========================================
echo Profile: %PROFILE%
echo Configuration: %CONFIGURATION%
if "%RUN_TESTS%"=="1" (
echo Run tests: Yes
) else (
echo Run tests: No
)
if "%RUN_TESTS%"=="1" (
echo.
echo [1/2] Running tests...
dotnet test "%TEST_PROJECT%" -c %CONFIGURATION% --nologo
if errorlevel 1 (
echo.
echo Tests failed. Publish stopped.
goto :cleanup_fail
)
) else (
echo.
echo [1/2] Skipping tests...
)
echo.
echo [2/2] Publishing %PROFILE% profile...
dotnet publish "%PROJECT_PATH%" -c %CONFIGURATION% --nologo /p:PublishProfile=%PROFILE%
if errorlevel 1 (
echo.
echo Publish failed.
goto :cleanup_fail
)
echo.
echo Publish completed successfully.
goto :cleanup_success
:parse_args
if "%~1"=="" exit /b 0
if /I "%~1"=="portable" (
set "PROFILE=Portable"
shift
goto :parse_args
)
if /I "%~1"=="single" (
set "PROFILE=Single"
shift
goto :parse_args
)
if /I "%~1"=="--portable" (
set "PROFILE=Portable"
shift
goto :parse_args
)
if /I "%~1"=="--single" (
set "PROFILE=Single"
shift
goto :parse_args
)
if /I "%~1"=="--skip-tests" (
set "RUN_TESTS=0"
shift
goto :parse_args
)
if /I "%~1"=="--no-pause" (
set "PAUSE_ON_EXIT=0"
shift
goto :parse_args
)
if /I "%~1"=="--help" goto :help
if /I "%~1"=="-h" goto :help
echo Unknown argument: %~1
echo Use --help to see available options.
exit /b 1
:choose_profile
echo.
echo Available publish profiles:
echo 1. Portable
echo 2. Single
set /p "choice=Choose publish profile (1/2): "
if "%choice%"=="1" (
set "PROFILE=Portable"
exit /b 0
)
if "%choice%"=="2" (
set "PROFILE=Single"
exit /b 0
)
echo Invalid choice.
exit /b 1
:ensure_dotnet
dotnet --version >nul 2>&1
if errorlevel 1 (
echo .NET SDK was not found in PATH.
exit /b 1
)
exit /b 0
:help
echo.
echo Usage:
echo publish.bat [portable^|single] [--skip-tests] [--no-pause]
echo.
echo Examples:
echo publish.bat portable
echo publish.bat single --skip-tests
echo.
exit /b 1
:cleanup_success
popd >nul
if "%PAUSE_ON_EXIT%"=="1" pause
exit /b 0
:cleanup_fail
popd >nul
:fail
if "%PAUSE_ON_EXIT%"=="1" pause
exit /b 1