-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.cake
162 lines (144 loc) · 4.91 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
160
161
162
#tool "nuget:?package=DependencyCheck.Runner.Tool&include=./**/dependency-check.sh&include=./**/dependency-check.bat"
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var solution = "Cake.DependencyCheck.sln";
var appName = "Cake.DependencyCheck";
var apiKey = EnvironmentVariable("NUGET_API_KEY") ?? "abcdef0123456789";
var buildNumber = EnvironmentVariable("APPVEYOR_BUILD_NUMBER") ?? "0";
var version = EnvironmentVariable("APPVEYOR_REPO_TAG_NAME") ?? "1.2.0";
Setup(context =>
{
if (!DirectoryExists("nuget"))
{
CreateDirectory("nuget");
}
});
Task("Clean")
.Does(() =>
{
CleanDirectory("nuget");
});
Task("Restore")
.Does(() =>
{
NuGetRestore(solution);
});
Task("Build")
.Does(() =>
{
MSBuild(solution, new MSBuildSettings
{
Verbosity = Verbosity.Minimal,
Configuration = configuration
});
});
Task("Test")
.Does(() =>
{
var testProjects = GetFiles("./test/**/*.csproj");
foreach (var testProject in testProjects)
{
var projectFile = MakeAbsolute(testProject).ToString();
var dotNetTestSettings = new DotNetCoreTestSettings
{
Configuration = configuration,
NoBuild = true
};
DotNetCoreTest(projectFile, dotNetTestSettings);
}
});
Task("Pack")
.Does(() =>
{
var nuGetPackSettings = new NuGetPackSettings
{
Id = appName,
Version = version,
Title = appName,
Authors = new[] { "Burak İnce" },
Owners = new[] { "Burak İnce", "cake-contrib" },
Description = "OWASP Dependency-Check is a utility that identifies project dependencies and checks if there are any known, publicly disclosed, vulnerabilities.",
Summary = "OWASP Dependency-Check is a utility that identifies project dependencies and checks if there are any known, publicly disclosed, vulnerabilities.",
IconUrl = new Uri("https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png"),
ProjectUrl = new Uri("https://github.com/burakince/Cake.DependencyCheck"),
LicenseUrl = new Uri("https://github.com/burakince/Cake.DependencyCheck/blob/master/LICENSE"),
Tags = new [] { "Cake", "OWASP", "DependencyCheck", "Security" },
RequireLicenseAcceptance = false,
Symbols = false,
NoPackageAnalysis = true,
Files = new []
{
new NuSpecContent
{
Source = "netstandard1.6/Cake.DependencyCheck.dll",
Target = "lib/netstandard1.6"
},
new NuSpecContent
{
Source = "netstandard1.6/Cake.DependencyCheck.xml",
Target = "lib/netstandard1.6"
},
new NuSpecContent
{
Source = "net45/Cake.DependencyCheck.dll",
Target = "lib/net45"
},
new NuSpecContent
{
Source = "net45/Cake.DependencyCheck.xml",
Target = "lib/net45"
},
new NuSpecContent
{
Source = "net46/Cake.DependencyCheck.dll",
Target = "lib/net46"
},
new NuSpecContent
{
Source = "net46/Cake.DependencyCheck.xml",
Target = "lib/net46"
}
},
BasePath = "./src/Cake.DependencyCheck/bin/release",
OutputDirectory = "./nuget"
};
NuGetPack(nuGetPackSettings);
});
Task("Update-Appveyor-Build-Version")
.Does(() =>
{
if (AppVeyor.IsRunningOnAppVeyor)
{
AppVeyor.UpdateBuildVersion(version + string.Concat("+", buildNumber));
}
else
{
Information("Not running on AppVeyor");
}
});
Task("Publish")
.Does(() =>
{
if (string.IsNullOrEmpty(apiKey))
{
throw new InvalidOperationException("Could not resolve Nuget API key.");
};
var packagePath = "./nuget/" + appName + "." + version + ".nupkg";
Information("Publishing: {0}", packagePath);
NuGetPush(packagePath, new NuGetPushSettings
{
Source = "https://www.nuget.org/api/v2/package",
ApiKey = apiKey
});
});
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Pack");
Task("AppVeyor")
.IsDependentOn("Default")
.IsDependentOn("Update-Appveyor-Build-Version")
.IsDependentOn("Publish");
RunTarget(target);