forked from punker76/code-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.cake
More file actions
127 lines (102 loc) · 3.86 KB
/
build.cake
File metadata and controls
127 lines (102 loc) · 3.86 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
//////////////////////////////////////////////////////////////////////
// TOOLS / ADDINS
//////////////////////////////////////////////////////////////////////
#tool paket:?package=vswhere
#addin paket:?package=Cake.Git
#addin paket:?package=Cake.Figlet
#addin paket:?package=Cake.Paket
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
if (string.IsNullOrWhiteSpace(target))
{
target = "Default";
}
var configuration = Argument("configuration", "Release");
if (string.IsNullOrWhiteSpace(configuration))
{
configuration = "Release";
}
var verbosity = Argument("verbosity", Verbosity.Normal);
if (string.IsNullOrWhiteSpace(configuration))
{
verbosity = Verbosity.Normal;
}
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
var repoName = "code-samples";
var local = BuildSystem.IsLocalBuild;
// Set build version
var latestInstallationPath = VSWhereProducts("*", new VSWhereProductSettings { Version = "[\"15.0\",\"16.0\"]" }).FirstOrDefault();
var msBuildPath = latestInstallationPath.CombineWithFilePath("./MSBuild/15.0/Bin/MSBuild.exe");
var gitBranch = GitBranchCurrent(".");
var branchName = gitBranch.FriendlyName;
var isDevelopBranch = StringComparer.OrdinalIgnoreCase.Equals("develop", branchName);
var isReleaseBranch = StringComparer.OrdinalIgnoreCase.Equals("master", branchName);
// Define global marcos.
Action Abort = () => { throw new Exception("a non-recoverable fatal error occurred."); };
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(context =>
{
if (!IsRunningOnWindows())
{
throw new NotImplementedException($"{repoName} will only build on Windows because it's not possible to target WPF and Windows Forms from UNIX.");
}
Information(Figlet(repoName));
Information("IsLocalBuild : {0}", local);
Information("Branch : {0}", branchName);
Information("Configuration : {0}", configuration);
Information("MSBuildPath : {0}", msBuildPath);
});
Teardown(context =>
{
// Executed AFTER the last task.
});
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("CleanOutput")
.ContinueOnError()
.Does(() =>
{
var directoriesToDelete = GetDirectories("./**/obj").Concat(GetDirectories("./**/bin"));
DeleteDirectories(directoriesToDelete, new DeleteDirectorySettings { Recursive = true, Force = true });
});
Task("Restore")
.Does(() =>
{
PaketRestore();
// var msBuildSettings = new MSBuildSettings { ToolPath = msBuildPath, ArgumentCustomization = args => args.Append("/m") };
// MSBuild(iconPacksSolution, msBuildSettings
// .SetConfiguration(configuration)
// .SetVerbosity(Verbosity.Minimal)
// .WithTarget("restore")
// );
});
Task("BuildAll")
.Does(() =>
{
//var msBuildSettings = new MSBuildSettings { ToolPath = msBuildPath, ArgumentCustomization = args => args.Append("/m") };
var msBuildSettings = new MSBuildSettings { ArgumentCustomization = args => args.Append("/m") };
var solutions = GetFiles("./**/*.sln");
foreach(var solution in solutions)
{
MSBuild(solution, msBuildSettings
.UseToolVersion(MSBuildToolVersion.VS2015) // for now
.SetMaxCpuCount(0)
.SetConfiguration(configuration)
.SetVerbosity(Verbosity.Normal)
);
}
});
// Task Targets
Task("Default")
.IsDependentOn("CleanOutput")
.IsDependentOn("Restore")
.IsDependentOn("BuildAll");
// Execution
RunTarget(target);