forked from de4dot/de4dot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
133 lines (110 loc) · 3.95 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
125
126
127
128
129
130
131
132
133
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
var buildDir = Directory("./") + Directory(configuration);
var netCoreVer = "netcoreapp2.2";
var netFrameworkVer = "net48";
var msBuildSettings = new MSBuildSettings()
{
Configuration = configuration,
MaxCpuCount = System.Environment.ProcessorCount,
Verbosity = Verbosity.Normal
};
var dotnetSettings = new DotNetCorePublishSettings
{
Framework = netCoreVer,
Configuration = "Release",
OutputDirectory = buildDir + Directory("publish-" + netCoreVer)
};
var cleanSettings = new DotNetCoreCleanSettings
{
Framework = dotnetSettings.Framework,
Configuration = dotnetSettings.Configuration,
OutputDirectory = dotnetSettings.OutputDirectory
};
var licensefiles = new [] {
"COPYING",
"LICENSE.de4dot.txt",
"LICENSE.dnlib.txt",
"LICENSE.ICSharpCode.SharpZipLib.txt",
"LICENSE.lzma.txt",
"LICENSE.lzmat.txt",
"LICENSE.QuickLZ.txt",
"LICENSE.randomc.txt"
};
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectories("./**/bin/" + configuration);
CleanDirectories("./**/obj");
CleanDirectory(buildDir);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore("./de4dot.netframework.sln");
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
// Use MSBuild
MSBuild("./de4dot.netframework.sln", msBuildSettings);
});
Task("NetCoreBuild")
.IsDependentOn("Build")
.Does(() =>
{
DotNetCorePublish("de4dot", dotnetSettings);
});
Task("NetCoreClean")
.IsDependentOn("NetCoreBuild")
.Does(() =>
{
DotNetCoreClean("de4dot", cleanSettings);
});
//Task("Run-Unit-Tests")
//.IsDependentOn("Build")
//.Does(() =>
//{
//NUnit3("./src/**/bin/" + configuration + "/*.Tests.dll", new NUnit3Settings {
//NoResults = true
//});
//});
Task("Zip-Files")
.IsDependentOn("NetCoreClean")
.Does(() =>
{
// .NET Framework
CreateDirectory(buildDir + Directory(netFrameworkVer) + Directory("LICENSE"));
CopyFiles(licensefiles, buildDir + Directory(netFrameworkVer) + Directory("LICENSE"));
DeleteFiles(GetFiles(MakeAbsolute(buildDir + Directory(netFrameworkVer)) + File("/*.pdb")));
DeleteFiles(GetFiles(MakeAbsolute(buildDir + Directory(netFrameworkVer)) + File("/*.xml")));
DeleteFiles(GetFiles(MakeAbsolute(buildDir + Directory(netFrameworkVer)) + File("/Test.Rename.*")));
Zip(buildDir + Directory(netFrameworkVer), Directory(configuration) + File("de4dot-" + netFrameworkVer + ".zip"));
// .NET Core
CreateDirectory(buildDir + Directory("publish-" + netCoreVer) + Directory("LICENSE"));
CopyFiles(licensefiles, buildDir + Directory("publish-" + netCoreVer) + Directory("LICENSE"));
DeleteFiles(GetFiles(MakeAbsolute(dotnetSettings.OutputDirectory) + File("/*.pdb")));
DeleteFiles(GetFiles(MakeAbsolute(dotnetSettings.OutputDirectory) + File("*.xml")));
Zip(dotnetSettings.OutputDirectory, Directory(configuration) + File("de4dot-" + netCoreVer + ".zip"));
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Zip-Files");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);