-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.cake
159 lines (122 loc) · 4.09 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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//#addin "nuget:?package=Cake.StyleCop&version=1.1.0"
//#addin "Cake.XdtTransform"
//#addin "Cake.SemVer"
#tool nuget:?package=NUnit.ConsoleRunner&version=3.7.0
var configuration = Argument("configuration", "Release");
struct PathStruct{
public DirectoryPath ProjectPath;
public DirectoryPath OutputPath;
public IEnumerable<FilePath> Solutions;
public DirectoryPath IntegrationTestPath;
public IEnumerable<FilePath> TestSolutions;
public IEnumerable<FilePath> IntegrationTests;
}
PathStruct Paths = new PathStruct{
ProjectPath = MakeAbsolute(Directory("./")),
OutputPath = MakeAbsolute(Directory("./Build")),
IntegrationTestPath = MakeAbsolute(Directory("./tests")),
Solutions = new []{new FilePath("Semiodesk.Trinity.sln")},
TestSolutions = new []{new FilePath("./tests/cilg-integration/cilg-integration.sln")},
IntegrationTests = new []{new FilePath("./tests/cilg-integration/run.cake")}//, new FilePath("./tests/nuget-integration/run.cake")}
};
void Clean(FilePath solution)
{
Section("Clean and remove obj");
MSBuild(solution, settings => settings
.SetConfiguration(configuration)
.WithTarget("Clean")
.SetVerbosity(Verbosity.Quiet));
var parsedSolution = ParseSolution(solution);
foreach( var project in parsedSolution.Projects )
{
var dir = GetDirectories(project.Path.GetDirectory()+"/obj");
CleanDirectories(dir);
}
}
void Build(FilePath solution)
{
Section("BEGIN: "+solution);
Clean(solution);
NuGetRestore(solution);
Section("Build");
MSBuild(solution, settings => settings
.SetConfiguration(configuration)
.WithTarget("Rebuild")
.SetVerbosity(Verbosity.Quiet));
Section("DONE: "+solution);
}
void Section(string info)
{
Information("\n****************************************\n* "+info+"\n****************************************\n");
}
Setup(context =>
{
foreach( var x in Paths.Solutions)
Information(x);
});
Task("Clean-Outputs")
.Does(() =>
{
CleanDirectory(Paths.OutputPath);
});
/*
Task("StyleCop")
.Does(() =>
{
StyleCopAnalyse(settings => settings
.WithSolution(solutionFile)
.WithSettings(File("./Settings.StyleCop"))
.ToResultFile(buildDir + File("StyleCopViolations.xml")));
});
*/
Task("Build")
.IsDependentOn("Clean-Outputs")
//.IsDependentOn("StyleCop") TODO: enable
.DoesForEach(Paths.Solutions, (solution, ctx) => {
Build(solution);
});
Task("Pack")
.IsDependentOn("Build")
.Does(() => {
MSBuild("./Trinity/Trinity.csproj", settings => settings
.SetConfiguration(configuration)
.WithTarget("pack")
.SetVerbosity(Verbosity.Quiet));
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
var testAssemblies = GetFiles(Paths.OutputPath+"/**/Trinity.Test.dll");
foreach(var asm in testAssemblies )
try
{
Information(asm);
//NUnit3(Paths.OutputPath+"/**/" + configuration + "/Trinity.Test.dll", new NUnit3Settings {
//
// });
}
catch(Exception) {}
});
Task("Documentation")
.IsDependentOn("Test")
.Does(()=>{
//DocFxBuild("./doc/docfx_project/docfx.json");
});
Task("Integration-Test-Build")
.IsDependentOn("Build")
.DoesForEach( Paths.TestSolutions, (solution) => {
Build(solution);
});
Task("Integration-Test")
.IsDependentOn("Pack")
.IsDependentOn("Integration-Test-Build")
.DoesForEach(Paths.IntegrationTests, (test) => {
CakeExecuteScript(test, new CakeSettings {
Arguments = new Dictionary<string, string>{
{ "configuration", configuration }
}});
});
Task("Default")
.IsDependentOn("Integration-Test");
RunTarget("Default");