forked from Live-Charts/Live-Charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
146 lines (114 loc) · 4.37 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
143
144
145
146
//Addins
#addin Cake.VersionReader
#addin Cake.FileHelpers
#addin Cake.Git
//Variables
var buildType = Argument("Configuration", "Release");
var target = Argument ("target", "Default");
var configuration = "AnyCPU";
Task("OutputArguments")
.Does(() =>
{
Information("Target: " + target);
Information("Build Type: " + buildType);
});
Task("Core")
.Does(() =>
{
Information("Building Core.PCL...");
BuildProject("./Core/Core.csproj", "./bin/Release", buildType, configuration, "v4.5");
Information("Building Core.Net40...");
BuildProject("./Core40/Core40.csproj", "./bin/Net40", buildType, configuration, "v4.0");
Information("Building Core.Net45...");
BuildProject("./Core40/Core40.csproj", "./bin/Net45", buildType, configuration, "v4.5");
Information("Packing Core...");
NugetPack("./Core/Core.nuspec", "./Core/bin/Release/LiveCharts.dll");
Information("-- Core Packed --");
});
Task("WPF")
.Does(() =>
{
var wpfPath = "./WpfView/wpfview.csproj";
Information("Building Wpf.Debug...");
BuildProject(wpfPath, "./bin/Debug", "Debug", configuration, "v4.0");
Information("Building Wpf.Net40...");
BuildProject(wpfPath, "./bin/net403", "Release", configuration, "v4.0");
Information("Building Wpf.Debug...");
BuildProject(wpfPath, "./bin/net45", "Release", configuration, "v4.5");
Information("Packing Wpf...");
NugetPack("./WpfView/WpfView.nuspec", "./WpfView/bin/net403/LiveCharts.Wpf.dll");
Information("-- WPF Packed --");
});
Task("WinForms")
.Does(() =>
{
var formsPath = "./WinFormsView/WinFormsView.csproj";
Information("Building WinForms.Debug...");
BuildProject(formsPath, "./bin/Debug", "Debug", configuration, "v4.0");
Information("Building WinForms.Net40...");
BuildProject(formsPath, "./bin/net403", "Release", configuration, "v4.0");
Information("Building WinForms.Debug...");
BuildProject(formsPath, "./bin/net45", "Release", configuration, "v4.5");
Information("Packing WinForms...");
NugetPack("./WinFormsView/WinFormsView.nuspec", "./WinFormsView/bin/net403/LiveCharts.WinForms.dll");
Information("-- WinForms Packed --");
});
Task("UWP")
.Does(() =>
{
Information("Building UWP...");
BuildProject("./UwpView/UwpView.csproj", "./bin/AnyCPU", buildType, "AnyCPU");
Information("Packing UWP...");
NugetPack("./UwpView/UwpView.nuspec", "./UwpView/bin/AnyCPU/LiveCharts.Uwp.dll");
Information("-- UWP Packed --");
});
Task("Default")
.IsDependentOn("OutputArguments")
.IsDependentOn("Core")
.IsDependentOn("WPF")
.IsDependentOn("WinForms")
.IsDependentOn("UWP");
//Entry point for Cake build
RunTarget (target);
//Helper Methods
//Build a project
public void BuildProject(string path, string outputPath, string configuration,
string platform, string targetVersion = null)
{
Information("Building " + path);
try
{
DotNetBuild(path, settings =>
{
settings.SetConfiguration(configuration)
.WithProperty("Platform", platform)
.WithTarget("Clean,Build")
.WithProperty("OutputPath", outputPath)
.SetVerbosity(Cake.Core.Diagnostics.Verbosity.Minimal);
if (targetVersion != null)
settings.WithProperty("TargetFrameworkVersion", targetVersion);
});
}
catch(Exception ex)
{
Error("An error occurred while trying to build {0} with {1}", path, configuration);
}
Information("Build completed");
}
//Pack into Nuget package
public void NugetPack(string nuspecPath, string mainBinaryPath)
{
Information("Packing " + nuspecPath);
var binary = MakeAbsolute(File(mainBinaryPath));
var binaryVersion = GetFullVersionNumber(binary);
ReplaceRegexInFiles(nuspecPath, "0.0.0.0", binaryVersion);
NuGetPack(nuspecPath, new NuGetPackSettings{
Verbosity = NuGetVerbosity.Quiet,
OutputDirectory = "./"
});
//We revert the nuspec file to the check out one, otherwise we cannot build it again with a new version
//This should rather use XmlPoke but cannot yet get it to work
var fullNuspecPath = MakeAbsolute(File(nuspecPath));
GitCheckout("./", fullNuspecPath);
Information("Packing completed");
}