-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.cake
66 lines (56 loc) · 1.74 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
#tool "nuget:?package=NuGet.CommandLine&version=6.3.1"
#tool "nuget:?package=GitVersion.CommandLine&version=5.11.1"
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var nugetApiToken = EnvironmentVariable("nuget_api_token");
var solution = File("Cake.DoInDirectory/Cake.DoInDirectory.sln");
Task("CleanRestore")
.Does(() =>
{
CleanDirectories("./**/bin");
CleanDirectories("./**/obj");
NuGetRestore(solution);
});
Task("Build")
.IsDependentOn("CleanRestore")
.Does(() =>
{
var version = GitVersion(new GitVersionSettings { UpdateAssemblyInfo = true });
if (AppVeyor.IsRunningOnAppVeyor) {
AppVeyor.UpdateBuildVersion(version.InformationalVersion);
}
MSBuild(solution, configurator =>
configurator
.WithProperty("PackageVersion", version.NuGetVersionV2)
.UseToolVersion(MSBuildToolVersion.VS2022)
.SetConfiguration(configuration)
.SetVerbosity(Verbosity.Minimal));
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
CakeExecuteScript("./test.cake");
});
Task("Publish")
.WithCriteria(AppVeyor.IsRunningOnAppVeyor)
.IsDependentOn("Test")
.Does(() =>
{
var file = GetFiles("./**/bin/Release/*.nupkg").First();
AppVeyor.UploadArtifact(file);
var tagged = AppVeyor.Environment.Repository.Tag.IsTag &&
!string.IsNullOrWhiteSpace(AppVeyor.Environment.Repository.Tag.Name);
if (tagged)
{
// Push the package.
NuGetPush(file, new NuGetPushSettings
{
Source = "https://www.nuget.org/api/v2/package",
ApiKey = nugetApiToken
});
}
});
Task("Default")
.IsDependentOn("Publish");
RunTarget(target);