-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbuild.cake
94 lines (71 loc) · 2.05 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
#tool "nuget:?package=NuGet.CommandLine&version=5.1.0"
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0"
var target = Argument("Target", "Full");
Setup<BuildState>(_ =>
{
var state = new BuildState
{
Paths = new BuildPaths
{
SolutionFile = MakeAbsolute(File("./Templates.sln")),
NuSpecFile = MakeAbsolute(File("./EMG.Templates.nuspec"))
}
};
CleanDirectory(state.Paths.OutputFolder);
return state;
});
Task("BuildTemplates")
.Does<BuildState>(state =>
{
DotNetCoreBuild(state.Paths.SolutionFile.ToString());
});
Task("Version")
.Does<BuildState>(state =>
{
var version = GitVersion();
var packageVersion = version.SemVer;
var buildVersion = $"{version.FullSemVer}+{DateTimeOffset.UtcNow:yyyyMMddHHmmss}";
state.Version = new VersionInfo
{
PackageVersion = packageVersion,
BuildVersion = buildVersion
};
Information($"Package version: {state.Version.PackageVersion}");
Information($"Build version: {state.Version.BuildVersion}");
if (BuildSystem.IsRunningOnAppVeyor)
{
AppVeyor.UpdateBuildVersion(state.Version.BuildVersion);
}
});
Task("Pack")
.IsDependentOn("Version")
.Does<BuildState>(state =>
{
var settings = new NuGetPackSettings
{
Version = state.Version.PackageVersion,
OutputDirectory = state.Paths.OutputFolder
};
NuGetPack(state.Paths.NuSpecFile, settings);
});
Task("Full")
//.IsDependentOn("BuildTemplates")
.IsDependentOn("Pack");
RunTarget(target);
public class BuildState
{
public VersionInfo Version { get; set; }
public BuildPaths Paths { get; set; }
}
public class VersionInfo
{
public string PackageVersion { get; set; }
public string BuildVersion {get; set; }
}
public class BuildPaths
{
public FilePath SolutionFile { get; set; }
public FilePath NuSpecFile { get; set; }
public DirectoryPath SolutionFolder => SolutionFile.GetDirectory();
public DirectoryPath OutputFolder => SolutionFolder.Combine("outputs");
}