-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.cake
113 lines (96 loc) · 3.53 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
#addin "Cake.Putty"
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var framework = Argument("framework", "netcoreapp2.0");
///////////////////////////////////////////////////////////////////////
// PARAMETERS FOR WINDOWS
///////////////////////////////////////////////////////////////////////
//var runtime = Argument("runtime", "win10-arm");
//var os = Argument("os", "windows");
//var destinationIp = Argument("destinationPi", "192.168.1.125");
//var destinationDirectory = Argument("destinationDirectory", @"c$\ConsoleApps\Test");
///////////////////////////////////////////////////////////////////////
// PARAMETERS FOR LINUX
///////////////////////////////////////////////////////////////////////
var runtime = Argument("runtime", "ubuntu.16.04-arm");
var os = Argument("os", "ubuntu");
var destinationIp = Argument("destinationPi", "192.168.1.110");
var destinationDirectory = Argument("destinationDirectory", @"/home/ubuntu/ConsoleApps/Test");
var username = Argument("username", "ubuntu");
var executableName = Argument("executableName", "SamplePi");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
var binaryDir = Directory("./bin");
var objectDir = Directory("./obj");
var publishDir = Directory("./publish");
var projectFile = "./" + executableName + ".csproj";
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectory(binaryDir);
CleanDirectory(objectDir);
CleanDirectory(publishDir);
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(projectFile);
});
Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
{
Framework = framework,
Configuration = configuration,
OutputDirectory = "./bin/"
};
DotNetCoreBuild(projectFile, settings);
});
Task("Publish")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetCorePublishSettings
{
Framework = framework,
Configuration = configuration,
OutputDirectory = "./publish/",
Runtime = runtime
};
DotNetCorePublish(projectFile, settings);
});
Task("Deploy")
.IsDependentOn("Publish")
.Does(() =>
{
var files = GetFiles("./publish/*");
if(runtime.StartsWith("win"))
{
var destination = @"\\" + destinationIp + @"\" + destinationDirectory;
CopyFiles(files, destination, true);
}
else
{
var destination = destinationIp + ":" + destinationDirectory;
var fileArray = files.Select(m => m.ToString()).ToArray();
Pscp(fileArray, destination, new PscpSettings
{
SshVersion = SshVersion.V2,
User = username
}
);
var plinkCommand = "chmod u+x,o+x " + destinationDirectory + "/" + executableName;
Plink(username + "@" + destination, plinkCommand);
}
});
Task("Default")
.IsDependentOn("Deploy");
RunTarget(target);