-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathbuild.cake
More file actions
60 lines (53 loc) · 1.91 KB
/
build.cake
File metadata and controls
60 lines (53 loc) · 1.91 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
#addin "nuget:?package=CommandLineParser&version=2.4.3"
#addin "nuget:?package=Cake.FileHelpers&version=4.0.1"
#tool "nuget:?package=NuGet.CommandLine&version=6.3.1"
var target = Argument("target", "Build-Solutions");
var configuration = Argument("configuration", "Debug");
var lang = Argument("lang", "csharp");
FilePathCollection slnFiles = new FilePathCollection();
//////////////////////////////////////////////////////////////////////
// SETUP
//////////////////////////////////////////////////////////////////////
Setup(setupContext =>
{
if (lang != "csharp" && lang != "vbnet")
{
throw new Exception("The --lang argument should be set to either \"csharp\" or \"vbnet\".");
}
});
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Locate-Solutions")
.Does(()=>
{
slnFiles.Add(GetFiles($"./{lang}/**/*.sln"));
Console.WriteLine("Solutions found:");
foreach (var f in slnFiles)
{
Console.WriteLine($"- {f}");
}
});
Task("Build-Solutions")
.IsDependentOn("Locate-Solutions")
.DoesForEach(GetFiles($"./{lang}/**/*.sln"), (slnFile) =>
{
if (!slnFile.ToString().Contains("MyOutlookAddIn"))
{
Console.WriteLine($"--- Building solution: {slnFile}");
NuGetRestore(slnFile);
MSBuildSettings settings = new MSBuildSettings{
Restore = true
};
settings.SetConfiguration(configuration)
.SetPlatformTarget(PlatformTarget.MSIL)
.WithTarget("Clean")
.WithTarget("Rebuild")
.WithProperty("RegisterForComInterop", "false");
MSBuild(slnFile, settings);
}
}).DeferOnError();
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);