1
1
// Install modules
2
- #module nuget : ? package = Cake . DotNetTool . Module & version = 0.1 .0
2
+ #module nuget : ? package = Cake . DotNetTool . Module & version = 0.2 .0
3
3
4
4
// Install addins.
5
- #addin "nuget:?package=Cake.Gitter&version=0.9 .0"
6
- #addin "nuget:?package=Cake.Docker&version=0.9.6 "
7
- #addin "nuget:?package=Cake.Npm&version=0.15 .0"
8
- #addin "nuget:?package=Cake.Incubator&version=3 .0.0 "
5
+ #addin "nuget:?package=Cake.Gitter&version=0.10 .0"
6
+ #addin "nuget:?package=Cake.Docker&version=0.9.9 "
7
+ #addin "nuget:?package=Cake.Npm&version=0.16 .0"
8
+ #addin "nuget:?package=Cake.Incubator&version=4 .0.2 "
9
9
#addin "nuget:?package=Cake.Json&version=3.0.0"
10
10
#addin "nuget:?package=Cake.Tfx&version=0.8.0"
11
11
#addin "nuget:?package=Cake.Gem&version=0.7.0"
12
12
#addin "nuget:?package=Cake.Coverlet&version=2.2.1"
13
13
#addin "nuget:?package=Cake.Codecov&version=0.5.0"
14
14
#addin "nuget:?package=Newtonsoft.Json&version=9.0.1"
15
+ #addin "nuget:?package=xunit.assert&version=2.4.1"
15
16
16
17
// Install tools.
17
- #tool "nuget:?package=NUnit.ConsoleRunner&version=3.9.0"
18
- #tool "nuget:?package=GitReleaseNotes&version=0.7.1"
18
+ #tool "nuget:?package=NUnit.ConsoleRunner&version=3.10.0"
19
19
#tool "nuget:?package=ILRepack&version=2.0.16"
20
- #tool "nuget:?package=Codecov&version=1.1 .0"
21
- #tool "nuget:?package=nuget.commandline&version=4.9.2 "
20
+ #tool "nuget:?package=Codecov&version=1.4 .0"
21
+ #tool "nuget:?package=nuget.commandline&version=4.9.4 "
22
22
23
23
// Install .NET Core Global tools.
24
24
#tool "dotnet:?package=GitReleaseManager.Tool&version=0.8.0"
27
27
#load "./build/parameters.cake"
28
28
#load "./build/utils.cake"
29
29
30
+ using Xunit;
30
31
//////////////////////////////////////////////////////////////////////
31
32
// PARAMETERS
32
33
//////////////////////////////////////////////////////////////////////
@@ -208,19 +209,19 @@ Task("Copy-Files")
208
209
. Does < BuildParameters > ( ( parameters ) =>
209
210
{
210
211
// .NET Core
211
- var netCoreDir = parameters . Paths . Directories . ArtifactsBinNetCore . Combine ( "tools" ) ;
212
+ var coreFxDir = parameters . Paths . Directories . ArtifactsBinCoreFx . Combine ( "tools" ) ;
212
213
DotNetCorePublish ( "./src/GitVersionExe/GitVersionExe.csproj" , new DotNetCorePublishSettings
213
214
{
214
- Framework = parameters . NetCoreVersion ,
215
+ Framework = parameters . CoreFxVersion ,
215
216
NoRestore = true ,
216
217
Configuration = parameters . Configuration ,
217
- OutputDirectory = netCoreDir ,
218
+ OutputDirectory = coreFxDir ,
218
219
MSBuildSettings = parameters . MSBuildSettings
219
220
} ) ;
220
221
221
222
// Copy license & Copy GitVersion.XML (since publish does not do this anymore)
222
- CopyFileToDirectory ( "./LICENSE" , netCoreDir ) ;
223
- CopyFileToDirectory ( $ "./src/GitVersionExe/bin/{ parameters . Configuration } /{ parameters . NetCoreVersion } /GitVersion.xml", netCoreDir ) ;
223
+ CopyFileToDirectory ( "./LICENSE" , coreFxDir ) ;
224
+ CopyFileToDirectory ( $ "./src/GitVersionExe/bin/{ parameters . Configuration } /{ parameters . CoreFxVersion } /GitVersion.xml", coreFxDir ) ;
224
225
225
226
// .NET 4.0
226
227
DotNetCorePublish ( "./src/GitVersionExe/GitVersionExe.csproj" , new DotNetCorePublishSettings
@@ -233,14 +234,14 @@ Task("Copy-Files")
233
234
MSBuildSettings = parameters . MSBuildSettings
234
235
} ) ;
235
236
236
- var ilMergDir = parameters . Paths . Directories . ArtifactsBinFullFxILMerge ;
237
+ var ilMergeDir = parameters . Paths . Directories . ArtifactsBinFullFxILMerge ;
237
238
var portableDir = parameters . Paths . Directories . ArtifactsBinFullFxPortable . Combine ( "tools" ) ;
238
239
var cmdlineDir = parameters . Paths . Directories . ArtifactsBinFullFxCmdline . Combine ( "tools" ) ;
239
240
240
241
// Portable
241
- PublishILRepackedGitVersionExe ( true , parameters . Paths . Directories . ArtifactsBinFullFx , ilMergDir , portableDir , parameters . Configuration , parameters . FullFxVersion ) ;
242
+ PublishILRepackedGitVersionExe ( true , parameters . Paths . Directories . ArtifactsBinFullFx , ilMergeDir , portableDir , parameters . Configuration , parameters . FullFxVersion ) ;
242
243
// Commandline
243
- PublishILRepackedGitVersionExe ( false , parameters . Paths . Directories . ArtifactsBinFullFx , ilMergDir , cmdlineDir , parameters . Configuration , parameters . FullFxVersion ) ;
244
+ PublishILRepackedGitVersionExe ( false , parameters . Paths . Directories . ArtifactsBinFullFx , ilMergeDir , cmdlineDir , parameters . Configuration , parameters . FullFxVersion ) ;
244
245
245
246
// Vsix
246
247
var tfsPath = new DirectoryPath ( "./src/GitVersionTfsTask/GitVersionTask" ) ;
@@ -250,9 +251,9 @@ Task("Copy-Files")
250
251
CopyDirectory ( portableDir . Combine ( "lib" ) , tfsPath . Combine ( "lib" ) ) ;
251
252
252
253
// Vsix dotnet core
253
- var tfsNetCorePath = new DirectoryPath ( "./src/GitVersionTfsTask/GitVersionNetCoreTask" ) ;
254
- EnsureDirectoryExists ( tfsNetCorePath ) ;
255
- CopyDirectory ( netCoreDir , tfsNetCorePath . Combine ( "netcore" ) ) ;
254
+ var tfsCoreFxPath = new DirectoryPath ( "./src/GitVersionTfsTask/GitVersionNetCoreTask" ) ;
255
+ EnsureDirectoryExists ( tfsCoreFxPath ) ;
256
+ CopyDirectory ( coreFxDir , tfsCoreFxPath . Combine ( "netcore" ) ) ;
256
257
257
258
// Ruby Gem
258
259
var gemPath = new DirectoryPath ( "./src/GitVersionRubyGem/bin" ) ;
@@ -398,9 +399,9 @@ Task("Zip-Files")
398
399
Zip ( cmdlineDir , parameters . Paths . Files . ZipArtifactPathDesktop , fullFxFiles ) ;
399
400
400
401
// .NET Core
401
- var netCoreDir = parameters . Paths . Directories . ArtifactsBinNetCore . Combine ( "tools" ) ;
402
- var coreclrFiles = GetFiles ( netCoreDir . FullPath + "/**/*" ) ;
403
- Zip ( netCoreDir , parameters . Paths . Files . ZipArtifactPathCoreClr , coreclrFiles ) ;
402
+ var coreFxDir = parameters . Paths . Directories . ArtifactsBinCoreFx . Combine ( "tools" ) ;
403
+ var coreclrFiles = GetFiles ( coreFxDir . FullPath + "/**/*" ) ;
404
+ Zip ( coreFxDir , parameters . Paths . Files . ZipArtifactPathCoreClr , coreclrFiles ) ;
404
405
} ) ;
405
406
406
407
Task( "Docker-Build" )
@@ -409,17 +410,45 @@ Task("Docker-Build")
409
410
. IsDependentOn ( "Copy-Files" )
410
411
. Does < BuildParameters > ( ( parameters ) =>
411
412
{
412
- if ( parameters . IsRunningOnWindows )
413
+ var images = parameters . IsRunningOnWindows
414
+ ? parameters . Docker . Windows
415
+ : parameters . IsRunningOnLinux
416
+ ? parameters . Docker . Linux
417
+ : Array . Empty < DockerImage > ( ) ;
418
+
419
+ foreach ( var dockerImage in images )
413
420
{
414
- DockerBuild ( "windows" , "nano" , "netcoreapp2.1" , parameters ) ;
415
- DockerBuild ( "windows" , "windowsservercore" , "net472" , parameters ) ;
421
+ DockerBuild ( dockerImage , parameters ) ;
416
422
}
417
- else if ( parameters . IsRunningOnLinux )
423
+ } ) ;
424
+
425
+ Task ( "Docker-Test" )
426
+ . WithCriteria < BuildParameters > ( ( context , parameters ) => ! parameters . IsRunningOnMacOS , "Docker can be tested only on Windows or Linux agents." )
427
+ . WithCriteria < BuildParameters > ( ( context , parameters ) => parameters . IsStableRelease ( ) || parameters . IsPreRelease ( ) , "Docker-Test works only for releases." )
428
+ . IsDependentOn ( "Docker-Build" )
429
+ . Does < BuildParameters > ( ( parameters ) =>
430
+ {
431
+ var currentDir = MakeAbsolute ( Directory ( "." ) ) ;
432
+ var containerDir = parameters . IsRunningOnWindows ? "c:/repo" : "/repo" ;
433
+ var settings = new DockerContainerRunSettings
418
434
{
419
- DockerBuild ( "linux" , "debian" , "netcoreapp2.1" , parameters ) ;
420
- DockerBuild ( "linux" , "debian" , "net472" , parameters ) ;
421
- DockerBuild ( "linux" , "centos7" , "netcoreapp2.1" , parameters ) ;
422
- DockerBuild ( "linux" , "fedora27" , "netcoreapp2.1" , parameters ) ;
435
+ Rm = true ,
436
+ Volume = new [ ] { $ "{ currentDir } :{ containerDir } " }
437
+ } ;
438
+
439
+ var images = parameters . IsRunningOnWindows
440
+ ? parameters . Docker . Windows
441
+ : parameters . IsRunningOnLinux
442
+ ? parameters . Docker . Linux
443
+ : Array . Empty < DockerImage > ( ) ;
444
+
445
+ foreach ( var dockerImage in images )
446
+ {
447
+ var tags = GetDockerTags ( dockerImage , parameters ) ;
448
+ foreach ( var tag in tags )
449
+ {
450
+ DockerTestRun ( settings , parameters , tag , containerDir ) ;
451
+ }
423
452
}
424
453
} ) ;
425
454
@@ -585,7 +614,7 @@ Task("Publish-Tfs")
585
614
} ;
586
615
587
616
TfxExtensionPublish ( parameters . Paths . Files . VsixOutputFilePath , settings ) ;
588
- TfxExtensionPublish ( parameters . Paths . Files . VsixNetCoreOutputFilePath , settings ) ;
617
+ TfxExtensionPublish ( parameters . Paths . Files . VsixCoreFxOutputFilePath , settings ) ;
589
618
} )
590
619
. OnError ( exception =>
591
620
{
@@ -628,6 +657,7 @@ Task("Publish-DockerHub")
628
657
. WithCriteria < BuildParameters > ( ( context , parameters ) => parameters . IsRunningOnAzurePipeline , "Publish-DockerHub works only on AzurePipeline." )
629
658
. WithCriteria < BuildParameters > ( ( context , parameters ) => parameters . IsStableRelease ( ) || parameters . IsPreRelease ( ) , "Publish-DockerHub works only for releases." )
630
659
. IsDependentOn ( "Docker-Build" )
660
+ . IsDependentOn ( "Docker-Test" )
631
661
. Does < BuildParameters > ( ( parameters ) =>
632
662
{
633
663
var username = parameters . Credentials . Docker . UserName ;
@@ -642,17 +672,15 @@ Task("Publish-DockerHub")
642
672
643
673
DockerLogin ( parameters . Credentials . Docker . UserName , parameters . Credentials . Docker . Password ) ;
644
674
645
- if ( parameters . IsRunningOnWindows )
646
- {
647
- DockerPush ( "windows" , "nano" , "netcoreapp2.1" , parameters ) ;
648
- DockerPush ( "windows" , "windowsservercore" , "net472" , parameters ) ;
649
- }
650
- else if ( parameters . IsRunningOnLinux )
675
+ var images = parameters . IsRunningOnWindows
676
+ ? parameters . Docker . Windows
677
+ : parameters . IsRunningOnLinux
678
+ ? parameters . Docker . Linux
679
+ : Array . Empty < DockerImage > ( ) ;
680
+
681
+ foreach ( var dockerImage in images )
651
682
{
652
- DockerPush ( "linux" , "debian" , "netcoreapp2.1" , parameters ) ;
653
- DockerPush ( "linux" , "debian" , "net472" , parameters ) ;
654
- DockerPush ( "linux" , "centos7" , "netcoreapp2.1" , parameters ) ;
655
- DockerPush ( "linux" , "fedora27" , "netcoreapp2.1" , parameters ) ;
683
+ DockerPush ( dockerImage , parameters ) ;
656
684
}
657
685
658
686
DockerLogout ( ) ;
0 commit comments