-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
116 lines (97 loc) · 3.06 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
#tool "nuget:?package=GitVersion.CommandLine"
#tool "nuget:?package=gitlink&version=2.4.0"
#tool "nuget:?package=vswhere"
var sln = new FilePath("Fetcher.sln");
var binDir = new DirectoryPath("bin");
var outputDir = new DirectoryPath("artifacts");
var target = Argument("target", "Default");
var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
Task("Clean").Does(() =>
{
CleanDirectories("./**/bin");
CleanDirectories("./**/obj");
CleanDirectories(binDir.FullPath);
CleanDirectories(outputDir.FullPath);
});
FilePath msBuildPath;
Task("ResolveBuildTools")
.Does(() =>
{
var vsLatest = VSWhereLatest();
msBuildPath = (vsLatest == null)
? null
: vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/MSBuild.exe");
});
GitVersion versionInfo = null;
Task("Version").Does(() => {
GitVersion(new GitVersionSettings {
UpdateAssemblyInfo = true,
OutputType = GitVersionOutput.BuildServer
});
versionInfo = GitVersion(new GitVersionSettings{ OutputType = GitVersionOutput.Json });
Information("VI:\t{0}", versionInfo.FullSemVer);
});
Task("Restore").Does(() => {
NuGetRestore(sln);
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Version")
.IsDependentOn("Restore")
.IsDependentOn("ResolveBuildTools")
.Does(() => {
var settings = new MSBuildSettings
{
Configuration = "Release",
ToolPath = msBuildPath
};
MSBuild(sln, settings);
});
Task("GitLink")
.WithCriteria(() => IsRunningOnWindows())
.IsDependentOn("Build")
.Does(() => {
GitLink(sln.GetDirectory(), new GitLinkSettings {
RepositoryUrl = "https://github.com/mgj/fetcher",
ArgumentCustomization = args => args.Append(
"-ignore fetcher.core.tests,fetcher.playground.core,fetcher.playground.droid,fetcher.playground.touch")
});
});
Task("PackageAll")
.IsDependentOn("GitLink")
.Does(() => {
EnsureDirectoryExists(outputDir);
var nugetSettings = new NuGetPackSettings {
Authors = new [] { "Mikkel Jensen" },
Owners = new [] { "Mikkel Jensen" },
IconUrl = new Uri("https://artm.dk/images/android-logo.png"),
ProjectUrl = new Uri("https://github.com/mgj/fetcher"),
LicenseUrl = new Uri("https://github.com/mgj/fetcher/blob/master/LICENSE"),
Copyright = "Copyright (c) Mikkel Jensen",
RequireLicenseAcceptance = false,
Version = versionInfo.NuGetVersion,
Symbols = false,
NoPackageAnalysis = true,
OutputDirectory = outputDir,
Verbosity = NuGetVerbosity.Detailed,
BasePath = "./nuspec"
};
nugetSettings.ReleaseNotes = ParseReleaseNotes("./releasenotes/fetcher.md").Notes.ToArray();
NuGetPack("./nuspec/artm.fetcher.nuspec", nugetSettings);
});
Task("UploadAppVeyorArtifact")
.IsDependentOn("PackageAll")
.WithCriteria(() => !isPullRequest)
.WithCriteria(() => isRunningOnAppVeyor)
.Does(() => {
Information("Artifacts Dir: {0}", outputDir.FullPath);
foreach(var file in GetFiles(outputDir.FullPath + "/*")) {
Information("Uploading {0}", file.FullPath);
AppVeyor.UploadArtifact(file.FullPath);
}
});
Task("Default")
.IsDependentOn("UploadAppVeyorArtifact")
.Does(() => {});
RunTarget(target);