-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.cake
142 lines (121 loc) · 4.03 KB
/
build.cake
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
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
#addin nuget:?package=SharpZipLib&version=1.1.0
#addin nuget:?package=Cake.Compression&version=0.2.3
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var platformArg = Argument("platformArg", "x64");
Information("Platform argument is: {0}", platformArg);
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
var assemblyInfo = ParseAssemblyInfo("./src/SharedAssemblyInfo.cs");
var appVersion = assemblyInfo.AssemblyVersion;
Information("Version: {0}", appVersion);
var platformTarget = PlatformTarget.MSIL;
var platformName = string.Empty;
switch (platformArg)
{
case "x86":
platformTarget = PlatformTarget.x86;
platformName = "win32";
break;
default:
platformTarget = PlatformTarget.x64;
platformName = "win64";
break;
}
Information("Platform name: {0}", platformName);
var buildDir = Directory("./src/AMI.Portable/bin") + Directory(platformArg) + Directory(configuration);
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
});
Task("Download-Dependencies")
.IsDependentOn("Clean")
.Does(() =>
{
var simpleITK_dir = string.Empty;
var simpleITK_zip = string.Empty;
var simpleITK_url = string.Empty;
switch (platformArg)
{
case "x86":
simpleITK_dir = "./libs/SimpleITK-1.2.0-CSharp-win32-x86";
simpleITK_zip = "./libs/SimpleITK-1.2.0-CSharp-win32-x86.zip";
simpleITK_url = "https://github.com/SimpleITK/SimpleITK/releases/download/v1.2.0/SimpleITK-1.2.0-CSharp-win32-x86.zip";
break;
default:
simpleITK_dir = "./libs/SimpleITK-1.2.0-CSharp-win64-x64";
simpleITK_zip = "./libs/SimpleITK-1.2.0-CSharp-win64-x64.zip";
simpleITK_url = "https://github.com/SimpleITK/SimpleITK/releases/download/v1.2.0/SimpleITK-1.2.0-CSharp-win64-x64.zip";
break;
}
if (!DirectoryExists(simpleITK_dir))
{
if (!FileExists(simpleITK_zip))
{
// Downloading SimpleITK
var outputPath = File(simpleITK_zip);
DownloadFile(simpleITK_url, outputPath);
}
// Unzipping SimpleITK
Unzip(simpleITK_zip, "./libs");
}
var simpleITK_file1 = "SimpleITKCSharpManaged.dll";
var simpleITK_file2 = "SimpleITKCSharpNative.dll";
CopyFile(Directory(simpleITK_dir) + File(simpleITK_file1), Directory("./libs") + File(simpleITK_file1));
CopyFile(Directory(simpleITK_dir) + File(simpleITK_file2), Directory("./libs") + File(simpleITK_file2));
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Download-Dependencies")
.Does(() =>
{
NuGetRestore("./src/AMI.sln");
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild("./src/AMI.sln", settings =>
settings.SetConfiguration(configuration).SetPlatformTarget(platformTarget));
}
else
{
// Use XBuild
XBuild("./src/AMI.sln", settings =>
settings.SetConfiguration(configuration));
}
});
Task("Zip-Build")
.IsDependentOn("Build")
.Does(() =>
{
Zip(buildDir, buildDir + File("AMI-Portable-" + appVersion + "-" + platformName + "-" + platformArg + ".zip"));
});
Task("Run-Unit-Tests")
.IsDependentOn("Zip-Build")
.Does(() =>
{
NUnit3("./src/**/bin/" + configuration + "/*.Tests.dll", new NUnit3Settings {
NoResults = true
});
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Run-Unit-Tests");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);