forked from ahives/HareDu2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.cake
More file actions
131 lines (109 loc) · 4.22 KB
/
build.cake
File metadata and controls
131 lines (109 loc) · 4.22 KB
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
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
#tool nuget:?package=GitVersion.CommandLine
var target = Argument<string>("target", "Default");
var configuration = Argument<string>("configuration", "Release");
var package = Argument<bool>("package", true);
var prerelease = Argument<bool>("develop", false);
var semver = Argument<string>("semver");
var product = "HareDu2";
var copyright = string.Format("Copyright (c) 2013-{0} Albert L. Hives, et al.", DateTime.Now.Year);
var solutionInfo = "./src/HareDu/SolutionVersion.cs";
var solution = "./src/HareDu.sln";
var buildPath = (DirectoryPath)(Directory("./src/HareDu/bin") + Directory(configuration));
var artifactsBasePath = (DirectoryPath)Directory("./artifacts");
var baseBinPath = artifactsBasePath.Combine("bin");
var bin452Path = baseBinPath.Combine("lib/net452");
var nugetPath = artifactsBasePath.Combine("nuget");
var bin452FullPath = MakeAbsolute(bin452Path).FullPath;
TaskSetup(context =>
{
var message = string.Format("Task {0} started", context.Task.Name);
Information(message);
});
TaskTeardown(context =>
{
var message = string.Format("Task {0} finished", context.Task.Name);
Information(message);
});
Task("Clean-Build-Folder")
.Does(() =>
{
CleanDirectory(artifactsBasePath);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean-Build-Folder")
.Does(() =>
{
NuGetRestore(solution);
});
Task("Perform-Versioning")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
var asmInfoSettings = new AssemblyInfoSettings
{
Product = product,
Copyright = copyright,
InformationalVersion = semver,
FileVersion = semver,
Version = prerelease ? string.Format("{0}-prerelease", semver) : semver
};
CreateAssemblyInfo(solutionInfo, asmInfoSettings);
});
Task("Build")
.IsDependentOn("Perform-Versioning")
.Does(() =>
{
// Add support for .NET Standard, .NET Core
MSBuild(solution, settings => settings.SetConfiguration(configuration));
});
Task("Copy-Build-Artifacts")
.IsDependentOn("Build")
.Does(() =>
{
EnsureDirectoryExists(bin452Path);
CopyFiles(string.Format("{0}/*.dll", buildPath.ToString()), bin452Path);
CopyFiles(string.Format("{0}/*.pdb", buildPath.ToString()), bin452Path);
CopyFiles(string.Format("{0}/*.xml", buildPath.ToString()), bin452Path);
CopyFiles(string.Format("{0}/*.config", buildPath.ToString()), bin452Path);
CopyFileToDirectory("license", artifactsBasePath);
});
Task("Create-NuGet-Package")
.WithCriteria(() => package == true)
.IsDependentOn("Copy-Build-Artifacts")
.Does(() =>
{
var files = GetFiles(bin452Path.ToString());
var nuspecBasePath = new DirectoryPath("./artifacts/nuspec");
//var nuspec = string.Format("{0}.nuspec", product);
var nuspec = "HareDu.nuspec";
EnsureDirectoryExists(nuspecBasePath);
var assemblyInfo = ParseAssemblyInfo(solutionInfo);
var packageSettings = new NuGetPackSettings
{
Id = product,
Title = product,
Description = "HareDu is a .NET API that can be used to manage and monitor a RabbitMQ server or cluster.",
Copyright = copyright,
ProjectUrl = new Uri("http://github.com/ahives/HareDu2"),
LicenseUrl = new Uri("http://www.apache.org/licenses/LICENSE-2.0"),
Owners = new []{"Albert L. Hives"},
Authors = new []{"Albert L. Hives", "Chris Patterson"},
Dependencies = new []
{
new NuSpecDependency { Id = "Newtonsoft.Json", Version = "11.0.2" }
},
Version = assemblyInfo.AssemblyVersion,
BasePath = bin452Path,
OutputDirectory = nuspecBasePath,
RequireLicenseAcceptance = true,
Symbols = false,
Files = files
.Select(file => new NuSpecContent { Source = file.ToString(), Target = "lib" })
.ToArray()
};
NuGetPack(nuspec, packageSettings);
});
Task("Default")
.IsDependentOn("Create-NuGet-Package");
RunTarget(target);