1- echo Restoring dotnet tools...
1+ @ ECHO OFF
2+
3+ REM Make environment variables local to the batch script
4+ SETLOCAL
5+
6+ REM Default local parameters (BUILD_MODE must remain empty, otherwise, 'help' doesn't work)
7+ SET BUILD_CONFIG = Release
8+ SET BUILD_MODE =
9+
10+ SET DOTNET_TEST_ARGS =
11+ SET DOTNET_TEST_PROJECT_LOCATION =
12+
13+ SET DOTNET_CI_ARGS = --blame-hang-timeout 60000ms --logger " trx;LogFileName=test-results-release.trx" --logger " console;verbosity=detailed"
14+ SET DOTNET_TEST_ARGS = --logger " console;verbosity=detailed"
15+ SET DOTNET_TEST_PROJECT_LOCATION = " .\src\FSharpy.TaskSeq.Test\FSharpy.TaskSeq.Test.fsproj"
16+
17+ REM This is used to get a 'rest of arguments' list, which allows passing
18+ REM other arguments to the dotnet build and test commands
19+ SET REST_ARGS = %*
20+
21+ :parseArgs
22+ IF " %~1 " == " build" (
23+ SET BUILD_MODE = build
24+ REM Drop 'build' from the remaining args
25+ CALL :shiftArg %REST_ARGS%
26+
27+ ) ELSE IF " %~1 " == " test" (
28+ SET BUILD_MODE = test
29+ REM Drop 'test' from the remaining args
30+ CALL :shiftArg %REST_ARGS%
31+
32+ ) ELSE IF " %~1 " == " ci" (
33+ SET BUILD_MODE = ci
34+ REM Drop 'ci' from the remaining args
35+ CALL :shiftArg %REST_ARGS%
36+
37+ ) ELSE IF " %~1 " == " " (
38+ REM No args, default: build
39+ SET BUILD_MODE = build
40+ SET BUILD_CONFIG = Release
41+ )
42+
43+ CALL :tryBuildConfig %REST_ARGS%
44+ ECHO Additional arguments: %REST_ARGS%
45+
46+ REM Main branching starts here
47+ IF " %BUILD_MODE% " == " build" GOTO :runBuild
48+ IF " %BUILD_MODE% " == " test" GOTO :runTest
49+ IF " %BUILD_MODE% " == " ci" GOTO :runCi
50+
51+
52+ REM Something wrong, we don't recognize the given arguments
53+ REM Display help:
54+
55+ ECHO Argument not recognized
56+ ECHO .
57+ ECHO Available options are:
58+ ECHO .
59+ ECHO build Run 'dotnet build' (default if omitted)
60+ ECHO test Run 'dotnet test' with default configuration and no CI logging.
61+ ECHO ci Run 'dotnet test' with CI configuration and TRX logging.
62+ ECHO .
63+ ECHO Optionally combined with:
64+ ECHO .
65+ ECHO release Build release configuration (default).
66+ ECHO debug Build debug configuration.
67+ ECHO .
68+ ECHO Any arguments that follow the special arguments will be passed on to 'dotnet test' or 'dotnet build'
69+ ECHO Such user-supplied arguments can only be given when one of the above specific commands is used.
70+ ECHO
71+ ECHO Optional arguments may be given with a leading '/' or '-', if so preferred.
72+ ECHO .
73+ ECHO Examples:
74+ ECHO .
75+ ECHO Run default build (release):
76+ ECHO build
77+ ECHO .
78+ ECHO Run debug build:
79+ ECHO build debug
80+ ECHO .
81+ ECHO Run debug build with detailed verbosity:
82+ ECHO build debug --verbosity detailed
83+ ECHO .
84+ ECHO Run the tests in default CI configuration
85+ ECHO build ci
86+ ECHO .
87+ ECHO Run the tests as in CI, but with the Debug configuration
88+ ECHO build ci -debug
89+ ECHO .
90+ ECHO Run the tests without TRX logging
91+ ECHO build test -release
92+ ECHO .
93+ GOTO :EOF
94+
95+ REM Normal building
96+ :runBuild
97+ ECHO Building for %BUILD_CONFIG% configuration...
98+ ECHO .
99+ ECHO Executing:
100+ ECHO dotnet build src/FSharpy.TaskSeq.sln -c %BUILD_CONFIG% %REST_ARGS%
101+ ECHO .
102+ dotnet tool restore
103+ dotnet build src/FSharpy.TaskSeq.sln -c %BUILD_CONFIG% %REST_ARGS%
104+ GOTO :EOF
105+
106+ REM Testing
107+ :runTest
108+ ECHO .
109+ ECHO Testing: %BUILD_CONFIG% configuration...
110+ ECHO .
111+ ECHO Restoring dotnet tools...
112+ dotnet tool restore
113+
114+ ECHO Executing:
115+ ECHO dotnet test -c %BUILD_CONFIG% %DOTNET_TEST_ARGS% %DOTNET_TEST_PROJECT_LOCATION% %REST_ARGS%
116+ dotnet test -c %BUILD_CONFIG% %DOTNET_TEST_ARGS% %DOTNET_TEST_PROJECT_LOCATION% %REST_ARGS%
117+ GOTO :EOF
118+
119+ REM Continuous integration
120+ :runCi
121+ ECHO .
122+ ECHO Continuous integration: %BUILD_CONFIG% configuration...
123+ ECHO .
124+ ECHO Restoring dotnet tools...
2125dotnet tool restore
3126
4- dotnet build src/FSharpy.TaskSeq.sln -c Release
127+ ECHO Executing:
128+ ECHO dotnet test -c %BUILD_CONFIG% %DOTNET_CI_ARGS% %DOTNET_TEST_PROJECT_LOCATION% %REST_ARGS%
129+ dotnet test -c %BUILD_CONFIG% %DOTNET_CI_ARGS% %DOTNET_TEST_PROJECT_LOCATION% %REST_ARGS%
130+ GOTO :EOF
131+
132+
133+ REM Callable label, will resume after 'CALL' line
134+ :tryBuildConfig
135+ IF " %~1 " == " release" (
136+ SET BUILD_CONFIG = Release
137+ CALL :shiftArg %REST_ARGS%
138+ )
139+ IF " %~1 " == " -release" (
140+ SET BUILD_CONFIG = Release
141+ CALL :shiftArg %REST_ARGS%
142+ )
143+ IF " %~1 " == " /release" (
144+ SET BUILD_CONFIG = Release
145+ CALL :shiftArg %REST_ARGS%
146+ )
147+ IF " %~1 " == " debug" (
148+ SET BUILD_CONFIG = Debug
149+ CALL :shiftArg %REST_ARGS%
150+ )
151+ IF " %~1 " == " -debug" (
152+ SET BUILD_CONFIG = Debug
153+ CALL :shiftArg %REST_ARGS%
154+ )
155+ IF " %~1 " == " /debug" (
156+ SET BUILD_CONFIG = Debug
157+ CALL :shiftArg %REST_ARGS%
158+ )
159+ GOTO :EOF
160+
161+ REM Callable label, will resume after 'CALL' line
162+ :shiftArg
163+ REM Do not call 'SHIFT' here, as we do it manually
164+ REM Here, '%*' means the arguments given in the CALL command to this label
165+ SET REST_ARGS = %*
166+
167+ REM Shift by stripping until and including the first argument
168+ IF NOT " %REST_ARGS% " == " " CALL SET REST_ARGS = %% REST_ARGS:*%1 =%%
169+ GOTO :EOF
0 commit comments