This repository has been archived by the owner on Jan 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.cake
84 lines (73 loc) · 2.73 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
#load "./buildconfig.cake"
var config = BuildConfig.Create(Context, BuildSystem);
Information("SrcDir: " + config.SrcDir);
Information("OutDir: " + config.OutDir);
Information("SemVer: " + config.SemVer);
Information("IsDefaultBranch: " + config.IsDefaultBranch);
Information("BuildVersion: " + config.BuildVersion);
Information("BuildProfile: " + config.BuildProfile);
Information("IsTeamCityBuild: " + config.IsTeamCityBuild);
Task("Default")
.IsDependentOn("InitOutDir")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("UnitTests");
Task("CI")
.IsDependentOn("Default")
.IsDependentOn("Pack");
/********************************************/
Task("InitOutDir").Does(() => {
EnsureDirectoryExists(config.OutDir);
CleanDirectory(config.OutDir);
});
Task("Restore").Does(() => {
foreach(var sln in GetFiles(config.SrcDir + "*.sln")) {
DotNetBuild(sln, settings =>
settings
.SetConfiguration(config.BuildProfile)
.SetVerbosity(Verbosity.Minimal)
.WithTarget("Restore")
.WithProperty("TreatWarningsAsErrors", "true"));
}
});
Task("Build").Does(() => {
foreach(var sln in GetFiles(config.SrcDir + "*.sln")) {
DotNetBuild(sln, settings =>
settings
.SetConfiguration(config.BuildProfile)
.SetVerbosity(Verbosity.Minimal)
.WithTarget("Rebuild")
.WithProperty("TreatWarningsAsErrors", "true")
.WithProperty("NoRestore", "true")
.WithProperty("Version", config.SemVer)
.WithProperty("AssemblyVersion", config.BuildVersion)
.WithProperty("FileVersion", config.BuildVersion));
}
});
Task("UnitTests").Does(() => {
var settings = new DotNetCoreTestSettings {
Configuration = config.BuildProfile,
NoBuild = true
};
foreach(var testProj in GetFiles(config.SrcDir + "tests/**/*.UnitTests.csproj")) {
DotNetCoreTest(testProj.FullPath, settings);
}
});
Task("Pack").Does(() => {
DeleteFiles(config.SrcDir + "projects/**/*.nupkg");
foreach(var sln in GetFiles(config.SrcDir + "projects/**/*.csproj")) {
DotNetBuild(sln, settings =>
settings
.SetConfiguration(config.BuildProfile)
.SetVerbosity(Verbosity.Minimal)
.WithTarget("Pack")
.WithProperty("TreatWarningsAsErrors", "true")
.WithProperty("NoRestore", "true")
.WithProperty("NoBuild", "true")
.WithProperty("Version", config.SemVer));
}
CopyFiles(
GetFiles(config.SrcDir + "projects/**/*.nupkg"),
config.OutDir);
});
RunTarget(config.Target);