-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
91 lines (74 loc) · 2.5 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
using System.Diagnostics;
#tool "nuget:?package=OctopusTools"
var target = Argument("target", "Default");
var build = Argument("build", "0");
var revision = Argument("revision", string.Empty);
var octopusUrl = Argument("octopusUrl", string.Empty);
var octopusApiKey = Argument("octopusApiKey", string.Empty);
var configuration = "Release";
var dotnetcoreVersion = "2.1";
Task("Clean")
.WithCriteria(!BuildSystem.IsRunningOnTeamCity)
.Does(() =>
{
var dirsToClean = GetDirectories("./**/bin");
dirsToClean.Add(GetDirectories("./**/obj"));
foreach(var dir in dirsToClean) {
Console.WriteLine(dir);
}
CleanDirectories(dirsToClean);
});
Task("Test")
.IsDependentOn("Clean")
.Does(() =>
{
GetFiles("./tests/**/*.csproj")
.ToList()
.ForEach(file => DotNetCoreTest(file.FullPath));
});
Task("Publish")
.IsDependentOn("Test")
.Does(() =>
{
DotNetCorePublish(".", new DotNetCorePublishSettings {
Configuration = configuration,
EnvironmentVariables = new Dictionary<string, string> {
{ "build", build },
{ "revision", revision }
}
});
});
Task("Pack")
.IsDependentOn("Publish")
.Does(() =>
{
var projectName = "Web";
var basePath = $"./src/{projectName}/bin/{configuration}/netcoreapp{dotnetcoreVersion}/publish";
var version = FileVersionInfo.GetVersionInfo($"{basePath}/{projectName}.dll").FileVersion;
OctoPack($"CakeXunitDemo.{projectName}", new OctopusPackSettings {
BasePath = basePath,
Format = OctopusPackFormat.Zip,
Version = version,
OutFolder = new DirectoryPath(".")
});
});
Task("OctoPush")
.IsDependentOn("Pack")
.WithCriteria(BuildSystem.IsRunningOnTeamCity)
.WithCriteria(!string.IsNullOrEmpty(octopusUrl))
.WithCriteria(!string.IsNullOrEmpty(octopusApiKey))
.Does(() =>
{
var packagePathCollection = new FilePathCollection(
System.IO.Directory.GetFiles(".", "CakeXunitDemo.*.zip").Select(filePath => new FilePath(filePath)),
new PathComparer(false));
OctoPush(
octopusUrl,
octopusApiKey,
packagePathCollection,
new OctopusPushSettings { ReplaceExisting = true }
);
});
Task("Default")
.IsDependentOn("OctoPush");
RunTarget(target);