forked from Azure/amqpnetlite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-2013.cmd
299 lines (255 loc) · 8.42 KB
/
build-2013.cmd
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
@ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion
ECHO Build Amqp.Net Lite
ECHO.
SET return-code=0
CALL :findfile MSBuild exe
IF "%MSBuildPath%" == "" (
ECHO MSBuild.exe does not exist or is not under PATH.
ECHO This can be resolved by building from a VS developer command prompt.
CALL :handle-error 1
GOTO :exit
)
SET build-target=build
SET build-config=Debug
SET build-platform=Any CPU
SET build-verbosity=minimal
SET build-dotnet=true
SET build-test=true
SET build-nuget=false
SET build-version=
IF /I "%1" EQU "release" (
set build-target=build
set build-config=Release
set build-dotnet=true
set build-nuget=true
GOTO :args-done
)
IF /I "%1" EQU "clean" (
set build-target=clean
GOTO :args-done
)
IF /I "%1" EQU "test" (
set build-target=test
GOTO :args-done
)
:args-start
IF /I "%1" EQU "" GOTO args-done
IF /I "%1" EQU "--dotnet" SET build-dotnet=true&&GOTO args-loop
IF /I "%1" EQU "--skiptest" SET build-test=false&&GOTO args-loop
IF /I "%1" EQU "--nuget" SET build-nuget=true&&GOTO args-loop
IF /I "%1" EQU "--config" GOTO :args-config
IF /I "%1" EQU "--platform" GOTO :args-platform
IF /I "%1" EQU "--verbosity" GOTO args-verbosity
SET return-code=1
GOTO :args-error
:args-config
SHIFT
SET build-config=%1
GOTO args-loop
:args-platform
SHIFT
SET build-platform=%1
GOTO args-loop
:args-verbosity
SHIFT
SET build-verbosity=%1
GOTO args-loop
:args-loop
SHIFT
GOTO :args-start
:args-error
CALL :handle-error 1
GOTO :exit
:args-done
ECHO Build target: %build-target%
ECHO Build configuration: %build-config%
ECHO Build platform: %build-platform%
ECHO Build dotnet: %build-dotnet%
ECHO Build run tests: %build-test%
ECHO Build NuGet package: %build-nuget%
ECHO.
IF /I "%build-config%" EQU "" GOTO :args-error
IF /I "%build-platform%" EQU "" GOTO :args-error
IF /I "%build-verbosity%" EQU "" GOTO :args-error
IF /I "%build-dotnet%" EQU "false" GOTO :build-start
CALL :findfile dotnet exe
IF "%dotnetPath%" == "" (
ECHO .Net Core SDK is not installed. If you unzipped the package, make sure the location is in PATH.
GOTO :exit
)
:build-start
IF /I "%build-target%" == "clean" GOTO :build-clean
IF /I "%build-target%" == "build" GOTO :build-target
IF /I "%build-target%" == "test" GOTO :build-done
GOTO :args-error
TASKKILL /F /IM TestAmqpBroker.exe >nul 2>&1
:build-clean
CALL :run-build Clean
SET return-code=%ERRORLEVEL%
GOTO :exit
:build-target
FOR /F "tokens=1-3* delims=() " %%A in (.\src\Properties\Version.cs) do (
IF "%%B" == "AssemblyInformationalVersion" SET build-version=%%C
)
IF "%build-version%" == "" (
ECHO Cannot find version from Version.cs.
SET return-code=2
GOTO :exit
)
echo Build version %build-version%
CALL :findfile NuGet exe
IF "%NuGetPath%" == "" (
ECHO NuGet.exe does not exist or is not under PATH.
) ELSE (
"%NuGetPath%" restore amqp-vs2013.sln
)
CALL :run-build Rebuild
IF %ERRORLEVEL% NEQ 0 (
SET return-code=%ERRORLEVEL%
GOTO :exit
)
:build-done
IF /I "%build-test%" EQU "false" GOTO :nuget-package
CALL :findfile MSTest exe
IF "%MSTestPath%" == "" (
ECHO MSTest.exe does not exist or is not under PATH. Will not run tests.
GOTO :exit
)
TASKLIST /NH /FI "IMAGENAME eq TestAmqpBroker.exe" | FINDSTR TestAmqpBroker.exe 1>nul 2>nul
IF %ERRORLEVEL% EQU 0 (
ECHO TestAmqpBroker is already running.
GOTO :run-test
)
SET TestBrokerPath=.\bin\%build-config%\TestAmqpBroker\TestAmqpBroker.exe
ECHO Starting the test AMQP broker
ECHO %TestBrokerPath% amqp://localhost:5672 amqps://localhost:5671 ws://localhost:18080 /creds:guest:guest /cert:localhost
START CMD.exe /C %TestBrokerPath% amqp://localhost:5672 amqps://localhost:5671 ws://localhost:18080 /creds:guest:guest /cert:localhost
rem Delay to allow broker to start up
PING -n 1 -w 2000 1.1.1.1 >nul 2>&1
:run-test
ECHO.
ECHO Running NET tests...
"%MSTestPath%" /testcontainer:.\bin\%build-config%\Test.Amqp.Net\Test.Amqp.Net.dll
IF %ERRORLEVEL% NEQ 0 (
SET return-code=%ERRORLEVEL%
ECHO Test failed!
TASKKILL /F /IM TestAmqpBroker.exe
IF /I "%is-elevated%" == "false" ECHO WebSocket tests may be failing because the broker was started without Administrator permission
GOTO :exit
)
ECHO.
ECHO Running NET40 tests...
"%MSTestPath%" /testcontainer:.\bin\%build-config%\Test.Amqp.Net40\Test.Amqp.Net40.dll
IF %ERRORLEVEL% NEQ 0 (
SET return-code=%ERRORLEVEL%
ECHO Test failed!
TASKKILL /F /IM TestAmqpBroker.exe
GOTO :exit
)
ECHO.
ECHO Running NET35 tests...
"%MSTestPath%" /testcontainer:.\bin\%build-config%\Test.Amqp.Net35\Test.Amqp.Net35.dll
IF %ERRORLEVEL% NEQ 0 (
SET return-code=%ERRORLEVEL%
ECHO Test failed!
TASKKILL /F /IM TestAmqpBroker.exe
GOTO :exit
)
ECHO.
ECHO Running DOTNET (.Net Core 1.0) tests...
IF /I "%build-dotnet%" EQU "false" GOTO done-test
"%dotnetPath%" run --configuration %build-config% --project dotnet\Test.Amqp -- no-broker
IF %ERRORLEVEL% NEQ 0 (
SET return-code=%ERRORLEVEL%
ECHO .Net Core Test failed!
GOTO :exit
)
:done-test
TASKKILL /F /IM TestAmqpBroker.exe
:nuget-package
IF /I "%build-nuget%" EQU "false" GOTO :exit
IF /I "%build-config%" NEQ "Release" (
ECHO Not building release. Skipping NuGet package.
GOTO :exit
)
rem Build NuGet package
ECHO.
IF "%NuGetPath%" == "" (
ECHO NuGet.exe does not exist or is not under PATH.
ECHO If you want to build NuGet package, install NuGet.CommandLine
ECHO package, or download NuGet.exe and place it under .\Build\tools
ECHO directory.
) ELSE (
IF NOT EXIST ".\Build\Packages" MKDIR ".\Build\Packages"
ECHO Building NuGet package with version %build-version%
"%NuGetPath%" pack .\nuspec\AMQPNetLite.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
IF %ERRORLEVEL% NEQ 0 (
SET return-code=%ERRORLEVEL%
GOTO :exit
)
"%NuGetPath%" pack .\nuspec\AMQPNetMicro.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
IF %ERRORLEVEL% NEQ 0 (
SET return-code=%ERRORLEVEL%
GOTO :exit
)
"%NuGetPath%" pack .\nuspec\AMQPNetLite.Core.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
IF %ERRORLEVEL% NEQ 0 (
SET return-code=%ERRORLEVEL%
GOTO :exit
)
"%NuGetPath%" pack .\nuspec\AMQPNetLite.Serialization.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
IF %ERRORLEVEL% NEQ 0 (
SET return-code=%ERRORLEVEL%
GOTO :exit
)
"%NuGetPath%" pack .\nuspec\AMQPNetLite.WebSockets.nuspec -Version %build-version% -BasePath .\ -OutputDirectory ".\Build\Packages"
IF %ERRORLEVEL% NEQ 0 (
SET return-code=%ERRORLEVEL%
GOTO :exit
)
)
GOTO :exit
:exit
EXIT /b %return-code%
:usage
ECHO build.cmd [clean^|release^|test] [options]
ECHO clean: clean intermediate files
ECHO release: a shortcut for "--config Release --nuget --dotnet"
ECHO test: run tests only from existing build
ECHO options:
ECHO --config ^<value^> [Debug] build configuration (e.g. Debug, Release)
ECHO --platform ^<value^> [Any CPU] build platform (e.g. Win32, x64, ...)
ECHO --dotnet [true] build dotnet
ECHO --verbosity ^<value^> [minimal] build verbosity (q[uiet], m[inimal], n[ormal], d[etailed] and diag[nostic])
ECHO --skiptest [false] skip test
ECHO --nuget [false] create NuGet packet (for Release only)
GOTO :eof
:handle-error
CALL :usage
SET return-code=%1
GOTO :eof
:run-build
ECHO Build solution amqp-vs2013.sln
"%MSBuildPath%" amqp-vs2013.sln /t:%1 /nologo /p:Configuration=%build-config%;Platform="%build-platform%" /verbosity:%build-verbosity%
IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL%
ECHO Build other versions of the micro NETMF projects
FOR /L %%I IN (2,1,3) DO (
"%MSBuildPath%" .\src\Amqp.Micro.NetMF.csproj /t:%1 /nologo /p:Configuration=%build-config%;Platform="%build-platform: =%";FrameworkVersionMajor=4;FrameworkVersionMinor=%%I /verbosity:%build-verbosity%
IF !ERRORLEVEL! NEQ 0 EXIT /b !ERRORLEVEL!
)
IF /I "%build-dotnet%" EQU "false" EXIT /b 0
IF /I "%1" EQU "Clean" EXIT /b 0
ECHO Build dotnet projects
CALL "%dotnetPath%" restore dotnet
IF !ERRORLEVEL! NEQ 0 EXIT /b !ERRORLEVEL!
CALL "%dotnetPath%" build dotnet/Amqp dotnet/Amqp.Serialization dotnet/Amqp.WebSockets.Client dotnet\HelloAmqp dotnet/Test.Amqp --configuration %build-config% --no-incremental
IF !ERRORLEVEL! NEQ 0 EXIT /b !ERRORLEVEL!
EXIT /b 0
:findfile
IF EXIST ".\Build\tools\%1.%2" (
SET %1Path=.\Build\tools\%1.%2
) ELSE (
FOR %%f IN (%1.%2) DO IF EXIST "%%~$PATH:f" SET %1Path=%%~$PATH:f
)
GOTO :eof