-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
158 lines (135 loc) · 4.55 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
#addin "Cake.Issues&prerelease"
#addin "Cake.Issues.MsBuild&prerelease"
#addin "Cake.Issues.InspectCode&prerelease"
#addin "Cake.Issues.Reporting&prerelease"
#addin "Cake.Issues.Reporting.Generic&prerelease"
#addin "Cake.Issues.PullRequests&prerelease"
#addin "Cake.Issues.PullRequests.AppVeyor&prerelease"
#tool "nuget:?package=MSBuild.Extension.Pack"
#tool "nuget:?package=JetBrains.ReSharper.CommandLineTools"
var target = Argument("target", "Default");
var repoRootFolder = MakeAbsolute(Directory("./"));
var outputFolder = repoRootFolder.Combine("output");
var msBuildXmlFileLoggerLog = outputFolder.CombineWithFilePath("msbuild-xmlfilelogger.log");
var msBuildBinLog = outputFolder.CombineWithFilePath("msbuild.binlog");
var inspectCodeLog = outputFolder.CombineWithFilePath("inspectCode.log");
var issues = new List<IIssue>();
Task("Build")
.Does(() =>
{
var solutionFile = repoRootFolder.Combine("src").CombineWithFilePath("ClassLibrary1.sln");
NuGetRestore(solutionFile);
var settings =
new MSBuildSettings()
.WithTarget("Rebuild");
// XML File Logger
settings =
settings.WithLogger(
Context.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath,
"XmlFileLogger",
string.Format(
"logfile=\"{0}\";verbosity=Detailed;encoding=UTF-8",
msBuildXmlFileLoggerLog));
// Binary Logger (use version from Cake.Issues.MsBuild to avoid unsupported file format versions)
settings =
settings.WithLogger(
Context.Tools.Resolve("Cake.Issues.MsBuild*/**/StructuredLogger.dll").FullPath,
"BinaryLogger",
msBuildBinLog.FullPath);
EnsureDirectoryExists(outputFolder);
MSBuild(solutionFile, settings);
if (AppVeyor.IsRunningOnAppVeyor)
{
AppVeyor.UploadArtifact(msBuildBinLog.FullPath);
}
});
Task("Run-InspectCode")
.Does(() =>
{
var settings = new InspectCodeSettings() {
OutputFile = inspectCodeLog
};
InspectCode(repoRootFolder.Combine("src").CombineWithFilePath("ClassLibrary1.sln"), settings);
});
Task("Read-Issues")
.IsDependentOn("Build")
.IsDependentOn("Run-InspectCode")
.Does(() =>
{
// Read issues from log files.
issues.AddRange(
ReadIssues(
MsBuildIssuesFromFilePath(
msBuildXmlFileLoggerLog,
MsBuildXmlFileLoggerFormat),
new ReadIssuesSettings(repoRootFolder)
{
Run = "MsBuildXmlFileLogger"
}));
issues.AddRange(
ReadIssues(
MsBuildIssuesFromFilePath(
msBuildBinLog,
MsBuildBinaryLogFileFormat),
new ReadIssuesSettings(repoRootFolder)
{
Run = "MsBuildBinaryLogFile"
}));
issues.AddRange(
ReadIssues(
new List<IIssueProvider>
{
InspectCodeIssuesFromFilePath(
inspectCodeLog)
},
new ReadIssuesSettings(repoRootFolder)));
// Add manual issue.
issues.Add(
NewIssue(
"Something went wrong",
"MyCakeScript",
"My Cake Script")
.InFile("myfile.txt", 42)
.WithPriority(IssuePriority.Warning)
.Create()
);
Information("{0} issues are found.", issues.Count());
});
Task("Create-Report")
.IsDependentOn("Read-Issues")
.Does(() =>
{
var reportFile = outputFolder.CombineWithFilePath("report.html");
var settings =
GenericIssueReportFormatSettings
.FromEmbeddedTemplate(GenericIssueReportTemplate.HtmlDxDataGrid)
.WithOption(HtmlDxDataGridOption.Theme, DevExtremeTheme.MaterialBlueLight);
// Create HTML report using DevExpress template.
CreateIssueReport(
issues,
GenericIssueReportFormat(settings),
repoRootFolder,
outputFolder.CombineWithFilePath("report.html"));
if (AppVeyor.IsRunningOnAppVeyor)
{
AppVeyor.UploadArtifact(reportFile);
}
});
Task("Report-IssuesToPullRequest")
.IsDependentOn("Read-Issues")
.WithCriteria(() => AppVeyor.IsRunningOnAppVeyor)
.Does(() =>
{
var appVeyorSettings =
new AppVeyorBuildSettings();
ReportIssuesToPullRequest(
MsBuildIssuesFromFilePath(
msBuildXmlFileLoggerLog,
MsBuildXmlFileLoggerFormat),
AppVeyorBuilds(appVeyorSettings),
repoRootFolder);
});
Task("Default")
.IsDependentOn("Report-IssuesToPullRequest")
.IsDependentOn("Create-Report");
RunTarget(target);