forked from FlaUI/FlaUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
154 lines (135 loc) · 4.86 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
#tool nuget:?package=NUnit.ConsoleRunner&version=3.7.0
#addin Cake.FileHelpers&version=1.0.4
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
var slnFile = @"src\FlaUI.sln";
var artifactDir = new DirectoryPath("artifacts");
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(artifactDir);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(slnFile);
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
var buildLogFile = artifactDir.CombineWithFilePath("BuildLog.txt");
var buildSettings = new MSBuildSettings {
Verbosity = Verbosity.Minimal,
ToolVersion = MSBuildToolVersion.VS2017,
Configuration = configuration,
PlatformTarget = PlatformTarget.MSIL,
}.AddFileLogger(new MSBuildFileLogger {
LogFile = buildLogFile.ToString(),
MSBuildFileLoggerOutput = MSBuildFileLoggerOutput.All
});
// Hide informational warnings for now
buildSettings.Properties.Add("WarningLevel", new[] { "3" });
// Force restoring
buildSettings.Properties.Add("RestoreForce", new[] { "true" });
// First build with default settings
buildSettings.Targets.Clear();
buildSettings.WithTarget("Restore");
MSBuild(slnFile, buildSettings);
buildSettings.Targets.Clear();
buildSettings.WithTarget("Build");
MSBuild(slnFile, buildSettings);
// Second build with signing enabled
var buildLogSignedFile = artifactDir.CombineWithFilePath("BuildLogSigned.txt");
buildSettings.FileLoggers.First().LogFile = buildLogSignedFile.ToString();
buildSettings.Properties.Add("EnableSigning", new[] { "true" });
buildSettings.Targets.Clear();
buildSettings.WithTarget("Restore");
MSBuild(slnFile, buildSettings);
buildSettings.Targets.Clear();
buildSettings.WithTarget("Build");
MSBuild(slnFile, buildSettings);
// Zip the logs
Zip(artifactDir, artifactDir.CombineWithFilePath("BuildLog.zip"), new [] { buildLogFile, buildLogSignedFile });
});
Task("Run-Unit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
var resultFile = artifactDir.CombineWithFilePath("UnitTestResult.xml");
NUnit3(@"src\FlaUI.Core.UnitTests\bin\FlaUI.Core.UnitTests.dll", new NUnit3Settings {
Results = resultFile
});
if (AppVeyor.IsRunningOnAppVeyor) {
AppVeyor.UploadTestResults(resultFile, AppVeyorTestResultsType.NUnit3);
}
});
Task("Run-UI-Tests")
.IsDependentOn("Build")
.Does(() =>
{
var resultFile = artifactDir.CombineWithFilePath("UIA2TestResult.xml");
NUnit3(@"src\FlaUI.Core.UITests\bin\FlaUI.Core.UITests.dll", new NUnit3Settings {
Results = resultFile,
ArgumentCustomization = args => args.Append("--params=uia=2")
});
if (AppVeyor.IsRunningOnAppVeyor) {
AppVeyor.UploadTestResults(resultFile, AppVeyorTestResultsType.NUnit3);
}
resultFile = artifactDir.CombineWithFilePath("UIA3TestResult.xml");
NUnit3(@"src\FlaUI.Core.UITests\bin\FlaUI.Core.UITests.dll", new NUnit3Settings {
Results = resultFile,
ArgumentCustomization = args => args.Append("--params=uia=3")
});
if (AppVeyor.IsRunningOnAppVeyor) {
AppVeyor.UploadTestResults(resultFile, AppVeyorTestResultsType.NUnit3);
}
});
Task("Run-Tests")
.IsDependentOn("Run-Unit-Tests")
.IsDependentOn("Run-UI-Tests")
.Does(() =>
{
});
Task("Package")
.IsDependentOn("Run-Tests")
.Does(() =>
{
// Upload the artifacts to appveyor
if (AppVeyor.IsRunningOnAppVeyor) {
// Add the nuget packages
foreach(var file in GetFiles(artifactDir.ToString() + "/*.nupkg"))
{
AppVeyor.UploadArtifact(file);
}
// Add the test xml files
foreach(var file in GetFiles(artifactDir.ToString() + "/*.xml"))
{
AppVeyor.UploadArtifact(file);
}
// Add zip files
foreach(var file in GetFiles(artifactDir.ToString() + "/*.zip"))
{
AppVeyor.UploadArtifact(file);
}
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Run-Unit-Tests");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);