forked from icsharpcode/AvaloniaILSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
115 lines (95 loc) · 3.58 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
var target = Argument("target", "Default");
var platform = Argument("platform", "AnyCPU");
var configuration = Argument("configuration", "Release");
var artifactsDir = (DirectoryPath)Directory("./artifacts");
var zipRootDir = artifactsDir.Combine("zips");
var fileZipSuffix = ".zip";
var netCoreAppsRoot= ".";
var netCoreApp = "ILSpy";
var buildDirs =
GetDirectories($"{netCoreAppsRoot}/**/bin/**") +
GetDirectories($"{netCoreAppsRoot}/**/obj/**") +
GetDirectories($"{netCoreAppsRoot}/artifacts/*");
var netCoreProject = new {
Path = $"{netCoreAppsRoot}/{netCoreApp}",
Name = netCoreApp,
Framework = XmlPeek($"{netCoreAppsRoot}/{netCoreApp}/{netCoreApp}.csproj", "//*[local-name()='TargetFramework']/text()"),
Runtimes = XmlPeek($"{netCoreAppsRoot}/{netCoreApp}/{netCoreApp}.csproj", "//*[local-name()='RuntimeIdentifiers']/text()").Split(';')
};
Task("Clean")
.Does(()=>{
CleanDirectories(buildDirs);
});
Task("Restore-NetCore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(netCoreProject.Path);
});
Task("Build-NetCore")
.IsDependentOn("Restore-NetCore")
.Does(() =>
{
Information("Building: {0}", netCoreProject.Name);
DotNetCoreBuild(netCoreProject.Path, new DotNetCoreBuildSettings {
Configuration = configuration
});
});
Task("Publish-NetCore")
.IsDependentOn("Restore-NetCore")
.Does(() =>
{
foreach(var runtime in netCoreProject.Runtimes)
{
var outputDir = artifactsDir.Combine(runtime);
Information("Publishing: {0}, runtime: {1}", netCoreProject.Name, runtime);
DotNetCorePublish(netCoreProject.Path, new DotNetCorePublishSettings {
Framework = netCoreProject.Framework,
Configuration = configuration,
Runtime = runtime,
SelfContained = true,
OutputDirectory = outputDir.FullPath
});
}
});
Task("Package-Mac")
.IsDependentOn("Publish-NetCore")
.Does(() =>
{
var runtimeIdentifiers = netCoreProject.Runtimes.Where(r => r.StartsWith("osx"));
foreach(var runtime in runtimeIdentifiers)
{
var workingDir = artifactsDir.Combine(runtime);
var tempDir = artifactsDir.Combine("app");
Information("Copying Info.plist");
EnsureDirectoryExists(tempDir.Combine("Contents"));
MoveFiles(workingDir.Combine("Info.plist").FullPath, tempDir.Combine("Contents"));
Information("Copying App Icons");
EnsureDirectoryExists(tempDir.Combine("Contents/Resources"));
MoveFiles(workingDir.Combine("ILSpy.icns").FullPath, tempDir.Combine("Contents/Resources"));
Information("Copying executables");
MoveDirectory(workingDir, tempDir.Combine("Contents/MacOS"));
Information("Finish packaging");
EnsureDirectoryExists(workingDir);
MoveDirectory(tempDir, workingDir.Combine($"{netCoreProject.Name}.app"));
}
});
/* Task("Zip-NetCore")
.IsDependentOn("Publish-NetCore")
.IsDependentOn("Package-Mac")
.Does(() =>
{
EnsureDirectoryExists(zipRootDir);
foreach(var runtime in netCoreProject.Runtimes)
{
var workingDir = artifactsDir.Combine(runtime);
Information("Zipping {0} artifacts to {1}", runtime, zipRootDir);
Zip(workingDir.FullPath, zipRootDir.CombineWithFilePath(netCoreProject.Name + "-" + runtime + "-" + configuration + fileZipSuffix));
}
}); */
Task("Default")
.IsDependentOn("Restore-NetCore")
.IsDependentOn("Publish-NetCore")
.IsDependentOn("Package-Mac")
/*.IsDependentOn("Zip-NetCore")*/;
RunTarget(target);