-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
120 lines (102 loc) · 3.27 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
#load "local:?path=build/clean.cake"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Build");
var githubRef = Argument("ref", string.Empty);
var version = Argument("package-version", "8.1.97");
var suffix = Argument("version-suffix", "alpha");
var configuration = Argument("configuration", "Release");
var platform = Argument("platform", "Any CPU");
var solution = Argument("solution", "FileOnQ.Imaging.Raw.sln");
var sample = Argument("sample", "./sample/FileOnQ.Imaging.Raw.Sample.sln");
var csproj = Argument("csproj", "./src/FileOnQ.Imaging.Raw/FileOnQ.Imaging.Raw.csproj");
var gpuProject = "./src/FileOnQ.Imaging.Raw.Gpu.Cuda/FileOnQ.Imaging.Raw.Gpu.Cuda.vcxproj";
//////////////////////////////////////////////////////////////////////
// MSBuild Settings
//////////////////////////////////////////////////////////////////////
var msbuildSettings = new MSBuildSettings
{
ToolVersion = MSBuildToolVersion.VS2019,
Configuration = configuration,
PlatformTarget = GetPlatform(platform)
};
PlatformTarget GetPlatform(string platform)
{
switch (platform)
{
case "Any CPU":
return PlatformTarget.MSIL;
case "x64":
return PlatformTarget.x64;
case "x86":
return PlatformTarget.x86;
case "Win32":
return PlatformTarget.Win32;
case "ARM64":
return PlatformTarget.ARM64;
case "ARM":
return PlatformTarget.ARM;
}
throw new Exception("Invalid platform");
}
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Restore")
.Does(() =>
{
NuGetRestore(solution);
});
Task("Build")
.Does(() =>
{
MSBuild(csproj, msbuildSettings);
});
Task("Build-GPU")
.Does(() =>
{
msbuildSettings.WorkingDirectory = "./src/FileOnQ.Imaging.Raw.Gpu.Cuda";
MSBuild("./src/FileOnQ.Imaging.Raw.Gpu.Cuda/FileOnQ.Imaging.Raw.Gpu.Cuda.vcxproj", msbuildSettings);
});
Task("Pack")
.Does(() =>
{
if (!string.IsNullOrEmpty(githubRef))
{
version = githubRef
.Split("/")
.LastOrDefault()
.TrimStart('v');
if (version.Contains("-dev."))
{
var segments = version.Split("-");
version = segments[0];
suffix = segments[1];
}
else
{
suffix = string.Empty;
}
}
MSBuild(csproj, msbuildSettings
.WithTarget("pack")
.WithProperty("PackageVersion", string.IsNullOrEmpty(suffix) ? version : $"{version}-{suffix}")
.WithProperty("Version", version)
.WithProperty("AssemblyVersion", version)
.WithProperty("PackageOutputPath", "../../"));
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("CI-Build")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("Build");
Task("Package-Build")
.IsDependentOn("CI-Build")
.IsDependentOn("Pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);