forked from erdomke/HttpClientPolyfill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
93 lines (81 loc) · 2.53 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
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configs = new string[] { "NET40", "NET35" };
string version;
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
var buildDir = Directory("./publish/HttpClientPolyfill/lib");
CleanDirectory(buildDir);
});
Task("Patch-Version")
.IsDependentOn("Clean")
.Does(() =>
{
var envCounter = int.Parse(EnvironmentVariable("BuildCounter") ?? "0");
var file = "./HttpClientPolyfill/Properties/AssemblyInfo.cs";
var info = ParseAssemblyInfo(file);
var parts = info.AssemblyVersion.Split('.');
var lastPart = int.Parse(parts[parts.Length - 1]) + 1;
lastPart = envCounter > lastPart ? envCounter : lastPart;
parts[parts.Length - 1] = lastPart.ToString();
version = string.Join(".", parts);
CreateAssemblyInfo(file, new AssemblyInfoSettings {
Product = "HttpClientPolyfill",
Version = version,
FileVersion = version,
Description = "A complete port of Mono's System.Net.Http assembly to .NET 3.5"
});
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Patch-Version")
.Does(() =>
{
NuGetRestore("./HttpClientPolyfill.sln");
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
foreach (var config in configs)
{
if(IsRunningOnWindows())
{
// Use MSBuild
MSBuild("./HttpClientPolyfill.sln", settings =>
settings.SetConfiguration(config));
}
else
{
// Use XBuild
XBuild("./HttpClientPolyfill.sln", settings =>
settings.SetConfiguration(config));
}
}
});
Task("NuGet-Pack")
.IsDependentOn("Build")
.Does(() =>
{
DeleteFiles("./HttpClientPolyfill.*.nupkg");
DeleteFiles("./publish/**/System.Threading.*");
var nuGetPackSettings = new NuGetPackSettings {
Version = version
};
NuGetPack("./publish/HttpClientPolyfill/HttpClientPolyfill.nuspec", nuGetPackSettings);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("NuGet-Pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);