-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.cake
155 lines (125 loc) · 5.05 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
147
148
149
150
151
152
153
154
155
#tool nuget:?package=GitVersion.CommandLine&version=5.5.0
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument<string>("target", "Default");
var configuration = Argument<string>("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
var buildDir = "."; //+ Directory(configuration);
string buildVersion = "";
//////////////////////////////////////////////////////////////////////
// Version
//////////////////////////////////////////////////////////////////////
GitVersion versionInfo = null;
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Version")
.Description("Retrieves the current version from the git repository")
.Does(() =>
{
versionInfo = GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = false
});
Information("Branch: "+ versionInfo.BranchName);
Information("Version: "+ versionInfo.FullSemVer);
Information("Version: "+ versionInfo.MajorMinorPatch);
if(versionInfo.BranchName != "master")
{
configuration = Argument("configuration", "Debug");
}
});
Task("Clean")
.IsDependentOn("Version")
.Does(() =>
{
Information("Cleaning: " + buildDir + "/src/**/bin");
CleanDirectories(buildDir + "/src/**/bin");
Information("Cleaning: " + buildDir + "/tests/**/bin");
CleanDirectories(buildDir + "/tests/**/bin");
Information("Cleaning: " + buildDir + "/src/**/obj");
CleanDirectories(buildDir + "/src/**/obj");
Information("Cleaning: " + buildDir + "/tests/**/obj");
CleanDirectories(buildDir + "/tests/**/obj");
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(buildDir + "/Reimers.Ihe.sln");
DotNetCoreBuildServerShutdown();
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
buildVersion = versionInfo.MajorMinorPatch + "-" + versionInfo.BranchName.Replace("features/", "") + "." + versionInfo.CommitsSinceVersionSource;
Information("Build version: " + buildVersion);
var informationalVersion = versionInfo.MajorMinorPatch + "." + versionInfo.CommitsSinceVersionSourcePadded;
Information("CommitsSinceVersionSourcePadded: " + versionInfo.CommitsSinceVersionSourcePadded);
if(versionInfo.BranchName == "master")
{
buildVersion = versionInfo.MajorMinorPatch;
}
var buildSettings = new DotNetCoreMSBuildSettings()
.SetConfiguration(configuration)
.SetVersion(buildVersion)
.SetInformationalVersion(informationalVersion);
DotNetCoreMSBuild(buildDir + "/Reimers.Ihe.sln", buildSettings);
DotNetCoreBuildServerShutdown();
});
Task("Tests")
.IsDependentOn("Build")
.Does(() =>
{
var projects = GetFiles(buildDir + "/tests/**/*.tests.csproj");
foreach(var project in projects)
{
Information("Testing: " + project.FullPath);
var reportName = buildDir + "/artifacts/testreports/" + versionInfo.FullSemVer + "_" + System.IO.Path.GetFileNameWithoutExtension(project.FullPath).Replace('.', '_') + ".xml";
reportName = System.IO.Path.GetFullPath(reportName);
Information(reportName);
var coreTestSettings = new DotNetCoreTestSettings()
{
NoBuild = true,
NoRestore = true,
// Set configuration as passed by command line
Configuration = configuration,
ArgumentCustomization = x => x.Append("--logger \"trx;LogFileName=" + reportName + "\"")
};
DotNetCoreTest(
project.FullPath,
coreTestSettings);
DotNetCoreBuildServerShutdown();
}
});
Task("Pack")
.IsDependentOn("Tests")
.Does(()=>
{
Information("Package version: " + buildVersion);
var packSettings = new DotNetCorePackSettings
{
Configuration = configuration,
NoBuild = false,
NoRestore = false,
OutputDirectory = "./artifacts/packages",
IncludeSymbols = true,
MSBuildSettings = new DotNetCoreMSBuildSettings().SetConfiguration(configuration).SetVersion(buildVersion)
};
DotNetCorePack("./src/Reimers.Ihe.Abstractions/Reimers.Ihe.Abstractions.csproj", packSettings);
DotNetCorePack("./src/Reimers.Ihe.Communication/Reimers.Ihe.Communication.csproj", packSettings);
DotNetCorePack("./src/Reimers.Ihe.Communication.Http/Reimers.Ihe.Communication.Http.csproj", packSettings);
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);