-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathbuild.cake
More file actions
120 lines (102 loc) · 3.83 KB
/
build.cake
File metadata and controls
120 lines (102 loc) · 3.83 KB
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
#tool nuget:?package=vswhere
#addin nuget:?package=Cake.Compression&version=0.1.1
#addin nuget:?package=SharpZipLib&version=0.86.0
ICSharpCode.SharpZipLib.Zip.ZipConstants.DefaultCodePage = 437;
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var platformTarget = Argument("platformTarget", "Any CPU");
var buildNumber = Argument("buildNumber", "0");
var buildDir = Directory("./artifacts");
var binDir = buildDir + Directory("bin");
var vsLatest = VSWhereLatest();
var modernMSBuildPath = vsLatest + File(@"\MSBuild\15.0\Bin\MSBuild.exe");
if (!FileExists(modernMSBuildPath)) {
modernMSBuildPath = vsLatest + File(@"\MSBuild\Current\bin\MSBuild.exe");
}
var modernMSTestPath = vsLatest + File(@"\Common7\IDE\MSTest.exe");
Task("Build")
.Does(() =>
{
CleanDirectory(binDir);
var solution = "./src/DiabloInterface.sln";
NuGetRestore(solution);
MSBuild(solution, settings =>
{
if (FileExists(modernMSBuildPath))
{
settings.ToolPath = modernMSBuildPath;
}
settings.SetConfiguration(configuration);
settings.SetVerbosity(Verbosity.Minimal);
if (platformTarget == "x64") {
settings.SetPlatformTarget(PlatformTarget.x64);
} else if (platformTarget == "x86") {
settings.SetPlatformTarget(PlatformTarget.x86);
}
});
var platformPart = "";
if (platformTarget == "x64" || platformTarget == "x86") {
platformPart = platformTarget + "/";
}
var path = "./src/DiabloInterface/bin/" + platformPart + configuration + "/";
var allFiles =
GetFiles(path + "*.dll") +
GetFiles(path + "*.exe") +
GetFiles(path + "*.config");
var files = allFiles.Where(x => !x.GetFilename().ToString().Contains(".vshost.exe"));
Information("Copying from {0}", path);
CopyFiles(files, binDir);
});
Task("Package")
.IsDependentOn("Build")
.Does(() =>
{
var platformPart = "";
if (platformTarget == "x64" || platformTarget == "x86") {
platformPart = "." + platformTarget;
}
var assemblyInfo = ParseAssemblyInfo("./src/DiabloInterface/Properties/AssemblyInfo.cs");
var fileName = string.Format(
"DiabloInterface-v{0}{1}.zip",
assemblyInfo.AssemblyInformationalVersion,
platformPart
);
CreateDirectory(binDir + Directory("Libs"));
CreateDirectory(binDir + Directory("Plugins"));
MoveFiles("./artifacts/bin/DiabloInterface.Plugin.*.dll", binDir + Directory("Plugins"));
MoveFiles("./artifacts/bin/*.dll", binDir + Directory("Libs"));
ZipCompress(binDir, buildDir + File(fileName));
});
Task("Default")
.IsDependentOn("Package");
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
foreach(var project in GetFiles("./src/*.Test/*.csproj"))
{
Information("Solution {0}", project);
var filename = project.GetFilenameWithoutExtension().ToString();
var testDir = Directory(project.GetDirectory().ToString() + "/bin/" + configuration + "/");
CleanDirectory(testDir);
CopyDirectory(binDir, testDir);
MSBuild(project, settings =>
{
if (FileExists(modernMSBuildPath))
settings.ToolPath = modernMSBuildPath;
settings.SetConfiguration(configuration);
settings.SetVerbosity(Verbosity.Minimal);
if (platformTarget == "x64") {
settings.SetPlatformTarget(PlatformTarget.x64);
} else if (platformTarget == "x86") {
settings.SetPlatformTarget(PlatformTarget.x86);
}
});
var s = new MSTestSettings();
s.ResultsFile = testDir + File(@"TestResults.trx");
if (FileExists(modernMSTestPath))
s.ToolPath = modernMSTestPath;
MSTest(testDir + File(filename + ".dll"), s);
}
});
RunTarget(target);