-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.cake
122 lines (107 loc) · 3.95 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
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define solutions.
var solutions = new Dictionary<string, string> {
{ "./src/Pictograms.sln", "Any" },
};
// Define AssemblyInfo source.
var assemblyInfoVersion = ParseAssemblyInfo("./src/Pictograms/Properties/AssemblyInfo.Common.cs");
var assemblyInfoCommon = assemblyInfoVersion;
// Define version.
var elapsedSpan = new TimeSpan(DateTime.Now.Ticks - new DateTime(2001, 1, 1).Ticks);
var assemblyVersion = assemblyInfoVersion.AssemblyVersion.Replace("*", elapsedSpan.Ticks.ToString().Substring(4, 4));
var version = EnvironmentVariable ("APPVEYOR_BUILD_VERSION") ?? Argument("version", assemblyVersion);
// Define directories.
var outputDirectory = "build/" + configuration;
var buildDir = Directory("../" + outputDirectory);
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
CleanDirectories("./**/bin");
CleanDirectories("./**/obj");
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
foreach (var solution in solutions)
{
NuGetRestore(solution.Key);
}
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
foreach (var solution in solutions)
{
if (IsRunningOnWindows())
{
var settings = new MSBuildSettings()
.WithProperty("PackageVersion", version)
.WithProperty("BuildSymbolsPackage", "false");
settings.SetConfiguration(configuration);
// Use MSBuild
MSBuild(solution.Key, settings);
}
else
{
var settings = new XBuildSettings()
.WithProperty("PackageVersion", version)
.WithProperty("BuildSymbolsPackage", "false");
settings.SetConfiguration(configuration);
// Use XBuild
XBuild(solution.Key, settings);
}
}
});
Task("Build-NuGet-Packages")
.IsDependentOn("Build")
.Does(() =>
{
foreach (var solution in solutions)
{
foreach (var folder in new System.IO.FileInfo(solution.Key).Directory.GetDirectories())
{
foreach (var file in folder.GetFiles("*.nuspec"))
{
var path = file.Directory;
var assemblyInfo = ParseAssemblyInfo(path + "/Properties/AssemblyInfo.cs");
var nuGetPackSettings = new NuGetPackSettings()
{
OutputDirectory = outputDirectory,
IncludeReferencedProjects = false,
//Id = assemblyInfo.Title.Replace(" ", "."),
Title = assemblyInfo.Title,
Version = version,
Authors = new[] { assemblyInfoCommon.Company },
Summary = assemblyInfo.Description,
Copyright = assemblyInfoCommon.Copyright,
Properties = new Dictionary<string, string>()
{{ "Configuration", configuration }}
};
NuGetPack(file.FullName, nuGetPackSettings);
}
}
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Build-NuGet-Packages");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);