forked from sshnet/SSH.NET
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.cake
124 lines (104 loc) · 4.03 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
//////////////////////////////////////////////////////////////////////
// TOOLS
//////////////////////////////////////////////////////////////////////
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0-beta0007"
#addin "Cake.FileHelpers"
#addin "Cake.ExtendedNuGet"
using Path = System.IO.Path;
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var solutionFile = "./src/Renci.SshNet.VS2017.sln";
///////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
///////////////////////////////////////////////////////////////////////////////
var artifactsDir = "./build/target/";
var tempDir = "./build/temp";
GitVersion gitVersionInfo;
string nugetVersion;
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(context =>
{
gitVersionInfo = GitVersion(new GitVersionSettings {
OutputType = GitVersionOutput.Json
});
// This seems to work better when off master than just NugetVersion.
nugetVersion = gitVersionInfo.MajorMinorPatch + "-" + gitVersionInfo.PreReleaseLabel + gitVersionInfo.CommitsSinceVersionSourcePadded;
if(BuildSystem.IsRunningOnTeamCity)
BuildSystem.TeamCity.SetBuildNumber(nugetVersion);
Information("Building SSH.NET v{0}", nugetVersion);
Information("Informational Version {0}", gitVersionInfo.InformationalVersion);
});
Teardown(context =>
{
Information("Finished running tasks.");
});
//////////////////////////////////////////////////////////////////////
// PRIVATE TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(artifactsDir);
CleanDirectory(tempDir);
CleanDirectories("./src/**/bin");
CleanDirectories("./src/**/obj");
CleanDirectories("./src/**/TestResults");
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() => {
NuGetRestore(solutionFile);
});
Task("Build")
.IsDependentOn("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
MSBuild("./src/Renci.SshNet/Renci.SshNet.csproj", settings => settings
.SetConfiguration(configuration)
.WithProperty("Version", nugetVersion)
.WithProperty("PackageVersion", nugetVersion)
.WithProperty("FileVersion", nugetVersion)
.WithTarget("Build"));
MSBuild("./src/Renci.SshNet.NETCore/Renci.SshNet.NETCore.csproj", settings => settings
.SetConfiguration(configuration)
.WithProperty("Version", nugetVersion)
.WithProperty("PackageVersion", nugetVersion)
.WithProperty("FileVersion", nugetVersion)
.WithTarget("Build"));
});
Task("Stage")
.IsDependentOn("Build")
.Does(() => {
CreateDirectory(Path.Combine(tempDir, "lib/net40"));
CreateDirectory(Path.Combine(tempDir, "lib/netstandard2.0"));
CopyFiles("./src/Renci.SshNet/bin/Release/*", Path.Combine(tempDir, "lib/net40"));
CopyFiles("./src/Renci.SshNet.NETCore/bin/Release/netstandard2.0/*", Path.Combine(tempDir, "lib/netstandard2.0"));
});
Task("Pack")
.IsDependentOn("Stage")
.Does(() =>
{
NuGetPack("./build/nuget/SSH.NET.nuspec", new NuGetPackSettings
{
Version = nugetVersion,
Symbols = false,
NoPackageAnalysis = true,
Files = new [] {
new NuSpecContent {Source = "*/**"},
},
BasePath = tempDir,
OutputDirectory = artifactsDir
});
});
Task("Default")
.IsDependentOn("Pack");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);