-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
295 lines (205 loc) · 9.01 KB
/
Makefile
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
SLN=Lib1.sln
PACKAGES_DIR=packages
LOCAL_NUGET_DIRECTORY=C:\NuGet
NUGET_OUTPUT_DIRECTORY=artifacts\NuGet
GITVERSION_VERSION=3.6.2
NUNIT_RUNNERS_VERSION=2.6.4
REPORT_UNIT_VERSION=1.2.1
DOTCOVER_VERSION=2016.2.20160913.100041
debug: package-debug reset
test: run-unit-tests generate-unit-test-report reset
cov: generate-code-coverage-report generate-unit-test-report reset
prod: package-release reset
all: package-debug generate-code-coverage-report generate-unit-test-report package-release doc reset
teamcity: package-debug capture-code-coverage package-release documentation reset
doc: documentation reset
@start docs\build\html\index.html
install-gitversion:
@echo ##teamcity[blockOpened name='Install GitVersion']
@nuget install GitVersion.CommandLine -Version $(GITVERSION_VERSION) -OutputDirectory $(PACKAGES_DIR)
@echo ##teamcity[blockClosed name='Install GitVersion']
install-nunit-runners:
@echo ##teamcity[blockOpened name='Install NUnit.Runners']
@nuget install NUnit.Runners -Version $(NUNIT_RUNNERS_VERSION) -OutputDirectory $(PACKAGES_DIR)
@echo ##teamcity[blockClosed name='Install NUnit.Runners']
install-dotcover:
@echo ##teamcity[blockOpened name='Install JetBrains.dotCover.CommandLineTools']
@nuget install JetBrains.dotCover.CommandLineTools -Version $(DOTCOVER_VERSION) -OutputDirectory $(PACKAGES_DIR)
@echo ##teamcity[blockClosed name='Install JetBrains.dotCover.CommandLineTools']
install-reportunit:
@echo ##teamcity[blockOpened name='Install ReportUnit']
@nuget install ReportUnit -Version $(REPORT_UNIT_VERSION) -OutputDirectory $(PACKAGES_DIR)
@echo ##teamcity[blockClosed name='Install ReportUnit']
version: install-gitversion
@echo ##teamcity[blockOpened name='Set Version']
@$(PACKAGES_DIR)\GitVersion.CommandLine.$(GITVERSION_VERSION)\tools\GitVersion.exe /updateassemblyinfo /output buildserver
@$(PACKAGES_DIR)\GitVersion.CommandLine.$(GITVERSION_VERSION)\tools\GitVersion.exe /showvariable NuGetVersion > version.txt
@call <<version.bat
@echo off
set /p VERSION= < version.txt
echo ##teamcity[buildNumber '%VERSION%']
<<
@echo ##teamcity[blockClosed name='Set Version']
restore:
@echo ##teamcity[blockOpened name='Install NuGet Packages']
@call <<restore.bat
nuget restore $(SLN)
if ERRORLEVEL 1 exit /b 1
<<
@echo ##teamcity[blockClosed name='Install NuGet Packages']
build-debug: version restore
@echo ##teamcity[blockOpened name='Build Solution (Debug)']
@echo ##teamcity[compilationStarted compiler='MSBuild']
@msbuild $(SLN) /m /p:Configuration=Debug
@echo ##teamcity[compilationFinished compiler='MSBuild']
@echo ##teamcity[blockClosed name='Build Solution (Debug)']
run-unit-tests: build-debug install-nunit-runners
@echo ##teamcity[blockOpened name='Run Unit Tests']
@call <<tests.bat
@echo off
if exist Reports rmdir /Q /S Reports
mkdir Reports\UnitTests
set NUNIT_CONSOLE=$(PACKAGES_DIR)\NUnit.Runners.$(NUNIT_RUNNERS_VERSION)\tools\nunit-console.exe
echo %NUNIT_CONSOLE%
pushd .
cd bin/Debug
for /f "delims=" %%i in ('dir *.UnitTests.dll /s/b') do (
..\..\%NUNIT_CONSOLE% %%i /result=..\..\Reports\UnitTests\%%~nxi.xml
)
popd
<<
@echo ##teamcity[blockClosed name='Run Unit Tests']
generate-unit-test-report: install-reportunit
@echo ##teamcity[blockOpened name='Generate Unit Test Report']
@$(PACKAGES_DIR)\ReportUnit.$(REPORT_UNIT_VERSION)\tools\ReportUnit.exe Reports\UnitTests
@start Reports\UnitTests\index.html
@echo ##teamcity[blockClosed name='Generate Unit Test Report']
capture-code-coverage: build-debug install-nunit-runners install-dotcover
@echo ##teamcity[blockOpened name='Capture Code Coverage']
@call <<coverage.bat
@echo off
if exist Reports rmdir /Q /S Reports
mkdir Reports\UnitTests
mkdir Reports\Coverage
set NUNIT_CONSOLE=$(PACKAGES_DIR)\NUnit.Runners.$(NUNIT_RUNNERS_VERSION)\tools\nunit-console.exe
set DOTCOVER=$(PACKAGES_DIR)\JetBrains.dotCover.CommandLineTools.$(DOTCOVER_VERSION)\tools\dotCover.exe
pushd .
cd bin/Debug
for /f "delims=" %%i in ('dir *.UnitTests.dll /s/b') do (
..\..\%DOTCOVER% c /TargetExecutable=..\..\%NUNIT_CONSOLE% /TargetArguments="%%i /result=..\..\Reports\UnitTests\%%~nxi.xml" /Output=..\..\Reports\Coverage\%%~nxi.dcvr /TargetWorkingDir=..\..
echo ##teamcity[importData type='dotNetCoverage' tool='dotcover' path='Reports\Coverage\%%~nxi.dcvr']
)
popd
<<
@echo ##teamcity[blockClosed name='Capture Code Coverage']
merge-code-coverage: capture-code-coverage
@echo ##teamcity[blockOpened name='Merge dotCover Reports']
@call <<merge.bat
@echo off
set DOTCOVER=$(PACKAGES_DIR)\JetBrains.dotCover.CommandLineTools.$(DOTCOVER_VERSION)\tools\dotCover.exe
pushd .
set COVERAGE_FILE=Reports\Coverage\Coverage.xml
if exist %COVERAGE_FILE% del %COVERAGE_FILE%
cd Reports\Coverage
echo ^<?xml version="1.0" encoding="utf-8"?^> > ..\..\%COVERAGE_FILE%
echo ^<MergeParams^> >> ..\..\%COVERAGE_FILE%
for /f "delims=" %%i in ('dir *.dcvr /s/b') do (
echo ^<Source^>%%i^</Source^> >> ..\..\%COVERAGE_FILE%
)
echo ^<Output^>MergedSnapshots.dcvr^</Output^> >> ..\..\%COVERAGE_FILE%
echo ^</MergeParams^> >> ..\..\%COVERAGE_FILE%
popd
%DOTCOVER% m %COVERAGE_FILE%
<<
@echo ##teamcity[blockClosed name='Merge dotCover Reports']
generate-code-coverage-report: merge-code-coverage
@echo ##teamcity[blockOpened name='Generate Code Coverage Report']
@call <<cov-report.bat
@echo off
set DOTCOVER=$(PACKAGES_DIR)\JetBrains.dotCover.CommandLineTools.$(DOTCOVER_VERSION)\tools\dotCover.exe
%DOTCOVER% r /Source=Reports\Coverage\MergedSnapshots.dcvr /Output=Reports\Coverage\CoverageReport.html /ReportType=html
del Reports\Coverage\Coverage.xml
del Reports\Coverage\*.dcvr
start Reports\Coverage\CoverageReport.html
<<
@echo ##teamcity[blockClosed name='Generate Code Coverage Report']
build-release: version restore
@echo ##teamcity[blockOpened name='Build Solution (Release)']
@echo ##teamcity[compilationStarted compiler='MSBuild']
@msbuild $(SLN) /m /p:Configuration=Release
@echo ##teamcity[compilationFinished compiler='MSBuild']
@echo ##teamcity[blockClosed name='Build Solution (Release)']
package-debug: build-debug
@echo ##teamcity[blockOpened name='Generate NuGet Packages (Debug)']
@if exist $(NUGET_OUTPUT_DIRECTORY)\Debug rd /S /Q $(NUGET_OUTPUT_DIRECTORY)\Debug
@md $(NUGET_OUTPUT_DIRECTORY)\Debug\Symbols
@if not exist $(LOCAL_NUGET_DIRECTORY) md $(LOCAL_NUGET_DIRECTORY)
@call <<package.bat
@echo off
set /p VERSION= < version.txt
echo %VERSION%
for /f "delims=" %%i in ('dir *.nuspec /s/b') do (
call :BUILD_NUGET_PACKAGE_DEBUG %%i
)
move /Y $(NUGET_OUTPUT_DIRECTORY)\Debug\*.symbols.nupkg $(NUGET_OUTPUT_DIRECTORY)\Debug\Symbols
copy $(NUGET_OUTPUT_DIRECTORY)\Debug\*.nupkg $(LOCAL_NUGET_DIRECTORY)
goto :eof
:BUILD_NUGET_PACKAGE_DEBUG
set file=%1
set file=%file:nuspec=csproj%
echo %file%
if not exist "%file%" goto :eof
nuget.exe pack %file% -OutputDirectory $(NUGET_OUTPUT_DIRECTORY)\Debug -IncludeReferencedProjects -Properties Configuration=Debug -Symbols -Version %VERSION%
goto :eof
<<
@echo ##teamcity[blockClosed name='Generate NuGet Packages (Debug)']
build-release: version restore
@echo ##teamcity[blockOpened name='Build Solution (Release)']
@echo ##teamcity[compilationStarted compiler='MSBuild']
@msbuild $(SLN) /m /nologo /p:Configuration=Release
@echo ##teamcity[compilationFinished compiler='MSBuild']
@echo ##teamcity[blockClosed name='Build Solution (Release)']
package-release: build-release
@echo ##teamcity[blockOpened name='Generate NuGet Packages (Release)']
@if exist $(NUGET_OUTPUT_DIRECTORY)\Release rd /S /Q $(NUGET_OUTPUT_DIRECTORY)\Release
@md $(NUGET_OUTPUT_DIRECTORY)\Release\Symbols
@if not exist $(LOCAL_NUGET_DIRECTORY) md $(LOCAL_NUGET_DIRECTORY)
@call <<package.bat
@echo off
set /p VERSION= < version.txt
echo %VERSION%
for /f "delims=" %%i in ('dir *.nuspec /s/b') do (
call :BUILD_NUGET_PACKAGE_RELEASE %%i
)
move /Y $(NUGET_OUTPUT_DIRECTORY)\Release\*.symbols.nupkg $(NUGET_OUTPUT_DIRECTORY)\Release\Symbols
goto :eof
:BUILD_NUGET_PACKAGE_RELEASE
set file=%1
set file=%file:nuspec=csproj%
echo %file%
if not exist "%file%" goto :eof
nuget.exe pack %file% -OutputDirectory $(NUGET_OUTPUT_DIRECTORY)\Release -IncludeReferencedProjects -Properties Configuration=Release -Symbols -Version %VERSION%
goto :eof
<<
@echo ##teamcity[blockClosed name='Generate NuGet Packages (Release)']
reset:
@git checkout *\AssemblyInfo.cs
@if exist version.txt del version.txt
documentation: version
@echo ##teamcity[blockOpened name='Generate Documentation']
@call <<docs.bat
@echo off
pushd .
cd docs
call make.bat html
popd
<<
@echo ##teamcity[blockClosed name='Generate Documentation']
clean:
@if exist docs\build rd /Q /S docs\build
@if exist packages rd /Q /S packages
@if exist artifacts rd /Q /S artifacts
@if exist Reports rd /Q /S Reports
@if exist version.txt del version.txt
@msbuild $(SLN) /m /t:Clean /p:Configuration=Debug
@msbuild $(SLN) /m /t:Clean /p:Configuration=Release