-
Notifications
You must be signed in to change notification settings - Fork 205
/
Common.Logging.build
693 lines (588 loc) · 27.3 KB
/
Common.Logging.build
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
<?xml version="1.0" ?>
<project name="Common.Logging" default="test" xmlns="http://nant.sf.net/schemas/nant.xsd">
<!-- Global project settings -->
<!-- 0 for initial or custom release, label value if built by ccnet -->
<property name="project.majorversion" value="2.0" />
<property name="project.patchversion" value="${CCNetLabel}" overwrite="true" if="${property::exists('CCNetLabel')}"/>
<property name="project.patchversion" value="0" overwrite="false" />
<property name="project.buildnumber" value="${math::abs(math::floor(timespan::get-total-days(datetime::now() - datetime::parse('01/01/2000'))))}" />
<property name="project.version" value="${project.majorversion}.${project.patchversion}.${project.buildnumber}" overwrite="false" />
<property name="package.version" value="${project.majorversion}.${project.patchversion}" overwrite="false" />
<!-- dev / alpha / beta# / rc# / release -->
<property name="project.releasetype" value="dev" overwrite="false" />
<property name="project.sign" value="false" overwrite="false" />
<property name="root.dir" value="${project::get-base-directory()}" overwrite="false" />
<property name="package.dir" value="${root.dir}/package" />
<property name="build.dir" value="${root.dir}/build" />
<property name="doc.dir" value="${root.dir}/doc" />
<property name="tool.dir" value="${root.dir}/tools" />
<property name="lib.dir" value="${root.dir}/lib" />
<property name="buildconfigflag.debug" value="true" overwrite="false"/>
<property name="buildconfigflag.release" value="true" overwrite="false"/>
<if test="${project.sign and not(file::exists(root.dir + '/Common.Net.snk'))}">
<fail message="project.sign='true' but keyfile ${root.dir+'/Common.Net.snk'} is missing" />
</if>
<call target="find-latest-msbuild.exe" />
<!--
find the latest installed version of MSBUILD.exe (can't assume always in the %SYSTEMROOM%\Microsoft.NET\Framework path
since later versions of MSBUILD (since .NET 4.5) don't rev with the Framework and instead install separately either as part of VS installation
or as a separate install of the "Microsoft Build Tools" MSI)
-->
<target name="find-latest-msbuild.exe">
<!-- assume we'll use the verison in the Framework folder as the default - note: this is the LAST version deployed w/ the Framwork -->
<readregistry property="net40.install.dir" key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\InstallPath" hive="LocalMachine" failonerror="true" />
<property name="msbuild.exe" value="${net40.install.dir}\msbuild.exe" />
<property name="progFiles.x86" value="${environment::get-variable('ProgramFiles(x86)')}" />
<!-- if there's one from VS 2013 installation, use it instead -->
<property name="msbuild.exe" value="${progFiles.x86}\MSBuild\12.0\Bin\msbuild.exe" if="${file::exists(progFiles.x86 + '\MSBuild\12.0\Bin\msbuild.exe')}" />
<!-- if there's one from VS 2015 installation, use it instead -->
<property name="msbuild.exe" value="${progFiles.x86}\MSBuild\14.0\Bin\msbuild.exe" if="${file::exists(progFiles.x86 + '\MSBuild\14.0\Bin\msbuild.exe')}" />
<echo message="Building all solutions using msbuild.exe found at ${msbuild.exe}" />
<echo message="If build is failing due to e.g., 'invalid numeric comparison' errors, ensure you have the latest MSBUILD tools installed from https://www.microsoft.com/en-us/download/details.aspx?id=48159" />
</target>
<target name="init" depends="clean, update-dependencies, restore-nuget-packages" />
<target name="build" depends="init">
<!-- force net-2.0 -->
<property name="nant.settings.currentframework" value="net-2.0"/>
<property name="solution-file-filter" value="*.2010-net20.sln" />
<property name="build.dir" value="${root.dir}/build/net20" />
<call target="build-all" />
<!-- force net-4.0 -->
<property name="nant.settings.currentframework" value="net-4.0"/>
<property name="solution-file-filter" value="*.2010.sln" />
<property name="build.dir" value="${root.dir}/build/net40" />
<call target="build-all" />
<!-- force net-4.5 -->
<property name="nant.settings.currentframework" value="net-4.5"/>
<property name="solution-file-filter" value="*.2013.sln" />
<property name="build.dir" value="${root.dir}/build/net45" />
<call target="build-all" />
<!-- force net-4.5 -->
<property name="nant.settings.currentframework" value="net-4.5"/>
<property name="solution-file-filter" value="*.2015.sln" />
<property name="build.dir" value="${root.dir}/build/net45" />
<setenv name="VisualStudioVersion" value="14.0" /> <!-- have to force VS version to 14.0 in order to resolve .NET Core MSBUILD target -->
<call target="build-all" />
<setenv name="VisualStudioVersion" value="" /> <!-- clear the env var so its not laying around causing trouble for other tasks -->
</target>
<target name="build-all" depends="init, update-common-assemblyinfo">
<if test="${buildconfigflag.debug}">
<property name="buildconfiguration" value="Debug" />
<call target="RebuildAllSolutions" />
</if>
<if test="${buildconfigflag.release}">
<property name="buildconfiguration" value="Release" />
<call target="RebuildAllSolutions" />
</if>
</target>
<target name="test" depends="build">
<property name="build.dir" value="${root.dir}/build" />
<call target="TestAllAssemblies" />
</target>
<target name="test-integration" depends="test">
<!--
<delete>
<fileset basedir="${build.dir}">
<include name="*.dll-TestCoverage.xml" />
</fileset>
</delete>
-->
<property name="build.dir" value="${root.dir}/build" />
<call target="IntegrationTestAllAssemblies" />
</target>
<target name="doc">
<call target="doc-reference" cascade="false" />
<!-- disabled since NDoc3 fails on x64 systems b/c of HtmlHelpCompiler being in c:\program files (x86)
instead of c:\program files\. Custom NDoc3 build will be needed :(
<call target="doc-sdk" cascade="false" />
-->
</target>
<target name="doc-reference">
<nant buildfile="${doc.dir}/reference/docbook.build" target="all" />
</target>
<target name="doc-sdk">
<echo message="Creating SDK Documentation for Common.Logging." />
<exec workingdir="." program="${tool.dir}/ndoc3/NDoc3Console.exe" verbose="true">
<!-- arg value="-verbose" /-->
<!-- arg value="-documenter=MSDN" /-->
<arg value="-project=${root.dir}/Common.Logging.ndoc" />
</exec>
</target>
<target name="deploy" depends="test-integration">
<delete dir="${deploy.dir}" failonerror="true" />
<copy todir="${deploy.dir}">
<fileset basedir="src/Viz.Invoicing.Front">
<include name="**/*.*"/>
<exclude name="Properties/**"/>
<exclude name="obj/**"/>
<exclude name="*.csproj*"/>
<exclude name="**/WebDev.WebHost.dll" />
</fileset>
</copy>
<copy todir="${deploy.dir}/bin">
<fileset basedir="${build.dir}">
<include name="*.dll"/>
<include name="*.pdb"/>
<exclude name="*.Tests.???" />
<exclude name="*.Tests.Integration.???" />
<exclude name="WebDev.WebHost.dll" />
</fileset>
</copy>
<xmlpoke
file="${deploy.dir}/Web.config"
xpath="/configuration/appSettings/add[@key = 'InvoicingManager.DeploymentProfile']/@value"
value="Viz.Invoicing.Configuration.LiveProfile" failonerror="true" />
<xmlpoke
file="${build.dir}/Viz.Invoicing.Deployment.dll.config"
xpath="/configuration/appSettings/add[@key = 'InvoicingManager.DeploymentProfile']/@value"
value="Viz.Invoicing.Configuration.LiveProfile" failonerror="true" />
<property name="test.assemblyname" value="${build.dir}/Viz.Invoicing.Deployment" />
<exec program="${tool.dir}/nunit/bin/net-2.0/nunit-console-x86.exe" workingdir="${build.dir}" verbose="true">
<arg line="${build.dir}/Viz.Invoicing.Deployment.dll" />
<arg value="/nologo" />
<arg value="/noshadow" />
<arg value="/framework:${nant.settings.currentframework}" />
<arg value="/run:Viz.Invoicing.Deployment.DeploymentFixture" />
</exec>
</target>
<target name="package-zip" depends="package" description="Build Package distribution as .zip file">
<property name="project.zip-path" value="${package.dir}/Common.Logging-${project.version}.zip"/>
<zip zipfile="${project.zip-path}">
<fileset basedir="${package.dir}">
<include name="**/*"/>
<exclude name="*.zip"/>
</fileset>
</zip>
</target>
<target name="package" description="Builds all modules and documentation">
<!-- clean package dir -->
<delete dir="${package.dir}" failonerror="true" />
<!-- build and copy binaries -->
<call target="package.binaries" cascade="false" />
<!-- copy sources -->
<call target="package.sources" cascade="false" />
<!-- create nuget packages -->
<call target="package-nuget" />
<!-- copy reference docs -->
<call target="package.doc" cascade="false"/>
<!-- build tools -->
<copy todir="${package.dir}/tools">
<fileset basedir="${root.dir}/tools">
<include name="**/*"/>
</fileset>
</copy>
<!-- copy over readme etc. -->
<copy todir="${package.dir}" file="${root.dir}/readme.md"/>
<copy todir="${package.dir}" file="${root.dir}/license.txt"/>
<copy todir="${package.dir}" file="${root.dir}/changelog.txt"/>
<!-- TODO: JUST FOR TESTING! -->
<!-- copy todir="${package.dir}\modules" file="${project.basedir}/modules/Common.Net.snk"/ -->
<!-- copy todir="${package.dir}\modules">
<fileset basedir="${project.basedir}\modules">
<include name="**/lib/**/Microsoft.*"/>
</fileset>
</copy -->
</target>
<target name="package.binaries" depends1="build">
<copy todir="${package.dir}/bin/net/2.0/debug" flatten="true">
<fileset>
<include name="**/build/net20/Common.Logging.*/Debug/Common.Logging*.???"/>
<exclude name="**/*Test*"/>
</fileset>
</copy>
<copy todir="${package.dir}/bin/net/2.0/release" flatten="true">
<fileset>
<include name="**/build/net20/Common.Logging.*/Release/Common.Logging*.???"/>
<exclude name="**/*Test*"/>
</fileset>
</copy>
<copy todir="${package.dir}/bin/net/4.0/debug" flatten="true">
<fileset>
<include name="**/build/net40/Common.Logging.*/Debug/Common.Logging*.???"/>
<exclude name="**/*Test*"/>
</fileset>
</copy>
<copy todir="${package.dir}/bin/net/4.0/release" flatten="true">
<fileset>
<include name="**/build/net40/Common.Logging.*/Release/Common.Logging*.???"/>
<exclude name="**/*Test*"/>
</fileset>
</copy>
<copy todir="${package.dir}/bin/net/4.5/debug" flatten="true">
<fileset>
<include name="**/build/net45/Common.Logging.*/Debug/Common.Logging*.???"/>
<exclude name="**/*Test*"/>
</fileset>
</copy>
<copy todir="${package.dir}/bin/net/4.5/release" flatten="true">
<fileset>
<include name="**/build/net45/Common.Logging.*/Release/Common.Logging*.???"/>
<exclude name="**/*Test*"/>
</fileset>
</copy>
</target>
<target name="package.sources" depends="update-common-assemblyinfo">
<!-- Copy global solution + build files -->
<copy todir="${package.dir}">
<fileset basedir="${root.dir}">
<include name="Common.Logging.*"/>
<exclude name="*.snk"/>
<exclude name="*.suo"/>
<exclude name="*.user"/>
<exclude name="*.cache"/>
</fileset>
</copy>
<!-- Copy Common.Logging sources -->
<copy todir="${package.dir}" failonerror="true" >
<fileset basedir="${root.dir}">
<include name="src/**/*.*"/>
<include name="test/**/*.*"/>
<include name="examples/**/*.*"/>
<exclude name="**/*.user"/>
</fileset>
</copy>
</target>
<target name="package.doc">
<!-- copy reference docs -->
<call target="doc" cascade="false"/>
<copy todir="${package.dir}/doc/reference/">
<fileset basedir="${doc.dir}/reference/target/">
<include name="**/*"/>
</fileset>
</copy>
<!-- copy sdk docs -->
<copy todir="${package.dir}/doc/api/html">
<fileset basedir="${doc.dir}/api/target/msdn/">
<include name="**/*"/>
<exclude name="*.chw" />
<exclude name="*.hhc" />
<exclude name="*.hhk" />
<exclude name="*.hhp" />
<exclude name="*.chm" />
<exclude name="ndoc3_msdn_temp" />
</fileset>
</copy>
<copy todir="${package.dir}/doc/api/htmlhelp">
<fileset basedir="${doc.dir}/api/target/msdn/">
<include name="*.chm"/>
</fileset>
</copy>
</target>
<target name="daily" depends="deploy">
</target>
<target name="clean">
<delete dir="${root.dir}/PreCompiledWeb" failonerror="true" />
<delete dir="${build.dir}" failonerror="true" />
<foreach item="Folder" property="dirname">
<in>
<items basedir="${root.dir}">
<exclude name="tools/**" />
<include name="src/**/bin" />
<include name="test/**/bin" />
<include name="**/obj" />
<include name="**/PreCompiledWeb" />
</items>
</in>
<do>
<delete dir="${dirname}" failonerror="false" />
</do>
</foreach>
</target>
<target name="common.run-tests">
<!-- call target="common.run-tests.nunit" / -->
<call target="common.run-tests.ncover" />
</target>
<!--
*******************************************************************************
Runs NUnit unit test configuration of the current ${project::get-name()}.dll
Arguments:
${build.dir}: the binary directory to pick the assembly + app.config from
${test.assemblyname} : (optional), the name of the assembly, if not specified uses "project:get-name()"
${tool.dir} : dir for tools
-->
<target name="common.run-tests.nunit">
<!-- property name="test.assemblyfile" value="${project::get-name()}.dll" overwrite="false" / -->
<property name="test.assemblyname" value="${path::get-file-name-without-extension(test.assemblyfile)}" overwrite="true" />
<property name="test.bin.dir" value="${directory::get-parent-directory(test.assemblyfile + '/')}" overwrite="true" />
<echo message="Unit Testing ${test.assemblyname}, File='${test.assemblyfile}', WorkingDir='${test.bin.dir}'" />
<exec program="${tool.dir}/nunit/nunit-console.exe" workingdir="${test.bin.dir}" verbose="true">
<arg value="/xml:${test.assemblyname}.dll-TestResults.xml" />
<arg value="/nologo" />
<arg value="/noshadow" />
<arg value="/framework:${nant.settings.currentframework}" />
<arg line="${test.assemblyfile}" />
</exec>
</target>
<!--
*******************************************************************************
Runs coverage unit test configuration of the current ${project::get-name()}.dll
Arguments:
${current.bin.dir}: the binary directory to pick the assembly + app.config from
${project.name} : (optional), the name of the assembly
${tool.dir} : dir for tools
-->
<target name="common.run-tests.ncover" description="Run NUnit tests">
<!-- property name="test.assemblyname" value="${project::get-name()}" overwrite="false" /-->
<property name="test.assemblyfile" value="${project::get-name()}.dll" overwrite="false" />
<property name="test.assemblyname" value="${path::get-file-name-without-extension(test.assemblyfile)}" overwrite="true" />
<property name="test.bin.dir" value="${directory::get-parent-directory(test.assemblyfile + '/')}" overwrite="true" />
<echo message="Coverage Testing ${test.assemblyname}, File='${test.assemblyfile}', WorkingDir='${test.bin.dir}'" />
<property name="test.assemblyname.tocover" value="${string::substring(test.assemblyname,0,string::last-index-of(test.assemblyname, '.Tests') )}" overwrite="true" />
<exec program="${tool.dir}/ncover/ncover.console.exe" workingdir="${test.bin.dir}" verbose="true">
<arg value="//q" />
<arg value="//reg" />
<arg value="//w" />
<arg path="${test.bin.dir}" />
<arg value="//x" />
<arg path="${test.bin.dir}/${test.assemblyname}.dll-TestCoverage.xml" />
<arg value="//a" />
<arg value="${test.assemblyname.tocover}" />
<arg value="//ea" />
<arg value="CoverageExcludeAttribute" />
<arg value="//q" />
<arg path="${tool.dir}/nunit/nunit-console-x86.exe" />
<arg line="${test.assemblyfile}" />
<arg value="/xml:${test.assemblyname}.dll-TestResults.xml" />
<arg value="/nologo" />
<arg value="/noshadow" />
<!--<arg value="/framework:${nant.settings.currentframework}" /> -->
</exec>
</target>
<target name="TestAllAssemblies">
<foreach item="File" property="filename">
<in>
<items basedir="${build.dir}">
<exclude name="net/**" />
<include name="**/*.Tests.dll" />
</items>
</in>
<do>
<property name="test.assemblyfile" value="${filename}" overwrite="true" />
<call target="common.run-tests" />
</do>
</foreach>
<!-- build coverage summary -->
<exec program="${tool.dir}/ncoverexplorer/ncoverexplorer.console.exe" workingdir="${build.dir}" failonerror="false">
<arg value="/xml:"${build.dir}/TestCoverageSummary.xml"" />
<arg value="/report:ModuleClassFunctionSummary" />
<arg value="/sort:4" />
<arg value="/minCoverage:80" />
<arg value="/q" />
<arg path="${build.dir}/*-TestCoverage.xml" />
</exec>
</target>
<target name="IntegrationTestAllAssemblies">
<foreach item="File" property="filename">
<in>
<items basedir="${build.dir}">
<exclude name="net/**" />
<include name="**/*.Tests.Integration.dll" />
<include name="**/*.Tests.Integration.*.dll" />
</items>
</in>
<do>
<property name="test.assemblyfile" value="${filename}" overwrite="true" />
<call target="common.run-tests" />
</do>
</foreach>
<!-- build coverage summary -->
<exec program="${tool.dir}/ncoverexplorer/ncoverexplorer.console.exe" workingdir="${build.dir}" failonerror="false">
<arg value="/xml:"${build.dir}/TestCoverageSummary.xml"" />
<arg value="/html:"${build.dir}/TestCoverageSummary.html"" />
<arg value="/report:ModuleClassFunctionSummary" />
<arg value="/sort:4" />
<arg value="/minCoverage:80" />
<arg value="/q" />
<arg path="${build.dir}/*-TestCoverage.xml" />
</exec>
</target>
<target name="RebuildAllSolutions">
<echo message="Building All Solutions with the following settings..." />
<echo message="nant.settings.currentframework = ${nant.settings.currentframework}" />
<echo message="build.dir = ${build.dir}" />
<echo message="solution-file-filter = ${solution-file-filter}" />
<echo message="buildconfiguration = ${buildconfiguration}" />
<foreach item="File" property="filename">
<in>
<items basedir="${root.dir}">
<exclude name="tools/**" />
<exclude name="package/**" />
<include name="**/${solution-file-filter}" />
</items>
</in>
<do>
<property name="solutionfile" value="${filename}" />
<property name="solutionconfiguration" value="${buildconfiguration}" />
<call target="RebuildSolution" />
</do>
</foreach>
</target>
<target name="RebuildSolution" description="rebuilds a given solution file">
<echo message="Rebuilding Solution ${solutionfile}" />
<exec program="${msbuild.exe}">
<!--
<arg value="/property:OutDir=${output.dir}/"/>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Common.Net.snk</AssemblyOriginatorKeyFile>
-->
<arg value="${solutionfile}"/>
<arg line="/property:SignAssembly=${project.sign},AssemblyOriginatorKeyFile=${root.dir}/Common.Net.snk" />
<arg line="/nologo" />
<arg line="/verbosity:minimal" />
<arg line="/property:Configuration=${solutionconfiguration}"/>
</exec>
</target>
<target name="update-dependencies">
<copy todir="${root.dir}" failonerror="false">
<fileset basedir="${root.dir}/../nonredist">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="update-common-assemblyinfo">
<!-- ensure src/CommonAssemblyInfo.cs is writable if it already exists -->
<attrib file="${root.dir}/src/CommonAssemblyInfo.cs" readonly="false" if="${file::exists('${root.dir}/src/CommonAssemblyInfo.cs')}" />
<property name="informational.version" value="${package.version}" />
<property name="informational.version" value="${package.version + '-' + nuget.version.suffix}" if="${property::exists('nuget.version.suffix')}"/>
<loadfile file="${root.dir}/src/CommonAssemblyInfo.cs.template" property="AssemblyInfoTemplateContents">
<filterchain>
<replacetokens>
<token key="ASSEMBLY_CONFIGURATION_ATTRIBUTE" value="${framework::get-target-framework()}.${platform::get-name()}; ${project.releasetype}" />
<token key="ASSEMBLY_INFORMATIONAL_VERSION_ATTRIBUTE" value="${informational.version}; ${framework::get-target-framework()}.${platform::get-name()}; ${project.releasetype}" />
<token key="INFORMATIONAL_VERSION" value="${informational.version}" />
<token key="ASSEMBLY_VERSION_ATTRIBUTE" value="${package.version}" />
</replacetokens>
</filterchain>
</loadfile>
<echo file="${root.dir}/src/CommonAssemblyInfo.cs" message="${AssemblyInfoTemplateContents}" />
</target>
<target name="check-nuget-package-dir">
<fail message="The NuGet package directory has not been specified."
if="${not property::exists('nuget.package.dir')}"/>
</target>
<target name="clean-nuget-package-dir" depends="check-nuget-package-dir" description="Cleans the NuGet package directory">
<echo message="Cleaning the ${nuget.package.dir} NuGet package directory."/>
<delete>
<fileset>
<include name="${nuget.package.dir}/*.nupkg" />
</fileset>
</delete>
<!--
<delete dir="${nuget.package.dir}" if="${directory::exists(nuget.package.dir)}"/>
<mkdir dir="${nuget.package.dir}"/>
-->
</target>
<target name="set-nuget-package-version" >
<!-- assume version of nuget package matches version of assemblies contained within it -->
<property name="nuget.package.version" value="${package.version}" />
<!-- if suffix is passed in, use it -->
<property name="nuget.package.version" value="${package.version + '-' + nuget.version.suffix}" if="${property::exists('nuget.version.suffix')}" />
</target>
<target name="package-nuget" depends="set-nuget-package-version,update-nuspec-metadata">
<property name="nuget.package.dir" value="${root.dir}/package-nuget" />
<call target="clean-nuget-package-dir" />
<!-- copy .NET Core dlls from build dirs -->
<copy todir="${root.dir}/build/netstandard1.0/Common.Logging.Core/Release">
<fileset basedir="src/Common.Logging.Core.DotNetCore/bin/Release/netstandard1.0">
<include name="Common.Logging.Core.dll"/>
<include name="Common.Logging.Core.pdb"/>
<include name="Common.Logging.Core.xml"/>
</fileset>
</copy>
<copy todir="${root.dir}/build/netstandard1.3/Common.Logging/Release">
<fileset basedir="src/Common.Logging.DotNetCore/bin/Release/netstandard1.3">
<include name="Common.Logging.dll"/>
<include name="Common.Logging.pdb"/>
<include name="Common.Logging.xml"/>
</fileset>
</copy>
<foreach item="File" property="filename">
<in>
<items basedir="${root.dir}/src/">
<include name="**/*.nuspec" />
</items>
</in>
<do>
<echo message="Generating NuGet Package from nuspec file: ${filename}" />
<exec program="${tool.dir}\NuGet\NuGet.exe" workingdir="${root.dir}" verbose="true">
<arg value="pack" />
<arg value="${filename}" />
<arg value="-Version" />
<arg value="${nuget.package.version}" />
<arg value="-OutputDirectory" />
<arg value="${nuget.package.dir}" />
</exec>
</do>
</foreach>
</target>
<target name="update-nuspec-metadata" depends="set-nuget-package-version">
<!--
INFO: this task assumes that all Common.Logging components are versioned coincident with each other and
updates all version dependencies betw. Common.Logging components at once
-->
<foreach item="File" property="filename">
<in>
<items basedir="${root.dir}/src/">
<include name="**/*.nuspec" />
<!--
NOTE: must exclude Common.Logging.Core.nuspec b/c it has no Common.Logging.* deps and so the XPATH expr. won't find a match in that case and so would fail the XMLPOKE operation otherwise
and Common.Logging as it uses different syntax
-->
<exclude name="**/Common.Logging.Core.nuspec" />
<exclude name="**/Common.Logging.nuspec" />
</items>
</in>
<do>
<echo message="Processing nuspec file: ${filename}" />
<xmlpoke file="${filename}" xpath="/n:package/n:metadata/n:dependencies/n:dependency[@id='Common.Logging' or @id='Common.Logging.Core' or @id='Common.Logging.Portable']/@version" value="${nuget.package.version}">
<namespaces>
<namespace prefix="n" uri="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" />
</namespaces>
</xmlpoke>
</do>
</foreach>
<!-- another round to poke values that are in grouped form (netstandard etc) -->
<foreach item="File" property="filename">
<in>
<items basedir="${root.dir}/src/">
<include name="**/Common.Logging.nuspec" />
</items>
</in>
<do>
<echo message="Processing nuspec file: ${filename}" />
<xmlpoke file="${filename}" xpath="/n:package/n:metadata/n:dependencies/n:group/n:dependency[@id='Common.Logging' or @id='Common.Logging.Core' or @id='Common.Logging.Portable']/@version" value="${nuget.package.version}">
<namespaces>
<namespace prefix="n" uri="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" />
</namespaces>
</xmlpoke>
</do>
</foreach>
</target>
<target name="restore-nuget-packages" description="Restores NuGet packages that solution(s) reference">
<exec
program="tools\nuget\nuget.exe"
commandline="restore Common.Logging.2010-net20.sln"
workingdir="."
failonerror="true" />
<exec
program="tools\nuget\nuget.exe"
commandline="restore Common.Logging.2010.sln"
workingdir="."
failonerror="true" />
<exec
program="tools\nuget\nuget.exe"
commandline="restore Common.Logging.2013.sln"
workingdir="."
failonerror="true" />
<exec
program="tools\nuget\nuget.exe"
commandline="restore Common.Logging.2015.sln"
workingdir="."
failonerror="true" />
<exec
program="dotnet"
commandline="restore"
workingdir="."
failonerror="true" />
</target>
</project>