-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.cake
92 lines (74 loc) · 2.44 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
#tool dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.10.3
#addin nuget:https://api.nuget.org/v3/index.json?package=Cake.Figlet&version=2.0.1
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var verbosityArg = Argument("verbosity", "Minimal");
var outputDirArg = Argument("outputDir", "./artifacts");
var verbosity = DotNetVerbosity.Minimal;
var gitVersionLog = new FilePath("./gitversion.log");
var sln = new FilePath("./ViewPagerIndicator.sln");
var outputDir = new DirectoryPath(outputDirArg);
var isGitHubActionsBuild = GitHubActions.IsRunningOnGitHubActions;
GitVersion versionInfo = null;
Setup(context =>
{
versionInfo = context.GitVersion(new GitVersionSettings
{
UpdateAssemblyInfo = true,
OutputType = GitVersionOutput.Json,
LogFilePath = gitVersionLog.MakeAbsolute(context.Environment)
});
var cakeVersion = typeof(ICakeContext).Assembly.GetName().Version.ToString();
Information(Figlet("ViewPagerIndicator"));
Information("Building version {0}, ({1}, {2}) using version {3} of Cake.",
versionInfo.SemVer,
configuration,
target,
cakeVersion);
verbosity = (DotNetVerbosity) Enum.Parse(typeof(DotNetVerbosity), verbosityArg, true);
});
Task("Clean").Does(() =>
{
CleanDirectories("./**/bin");
CleanDirectories("./**/obj");
CleanDirectories(outputDir.FullPath);
EnsureDirectoryExists(outputDir);
});
Task("Restore")
.Does(() =>
{
DotNetRestore(sln.ToString());
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.Does(() =>
{
var msBuildSettings = new DotNetMSBuildSettings
{
Version = versionInfo.SemVer,
PackageVersion = versionInfo.SemVer,
InformationalVersion = versionInfo.InformationalVersion
};
var settings = new DotNetBuildSettings
{
Configuration = configuration,
Verbosity = verbosity,
MSBuildSettings = msBuildSettings
};
DotNetBuild(sln.ToString(), settings);
});
Task("CopyArtifacts")
.IsDependentOn("Build")
.Does(() =>
{
var nugetFiles = GetFiles("Library/bin/" + configuration + "/**/*.nupkg");
CopyFiles(nugetFiles, outputDir);
CopyFileToDirectory(gitVersionLog, outputDir);
});
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("CopyArtifacts");
RunTarget(target);