-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
79 lines (78 loc) · 2.97 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
var configuration = Argument("Configuration", "Debug");
var target = Argument("Target", "Default");
Task("Default")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Pack")
;
Task("Restore")
.Does(() =>
{
DotNetCoreRestore("MSBuild.Sdk.CMake.slnproj");
});
Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
var buildSettings = new DotNetCoreBuildSettings();
buildSettings.Configuration = configuration;
DotNetCoreBuild("MSBuild.Sdk.CMake.slnproj", buildSettings);
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
foreach(var projectName in new []{ "Install", "Regular" })
{
var regularProjectDir = DirectoryPath.FromString("tests").Combine(projectName);
var projectFilePath = regularProjectDir.CombineWithFilePath($"{projectName}.cmproj");
var cleanSettings = new DotNetCoreCleanSettings();
cleanSettings.Configuration = configuration;
DotNetCoreClean(projectFilePath.ToString(), cleanSettings);
var buildSettings = new DotNetCoreBuildSettings();
buildSettings.Configuration = configuration;
DotNetCoreBuild(projectFilePath.ToString(), buildSettings);
}
});
Task("Pack")
.IsDependentOn("Build")
.Does(() =>
{
DotNetCorePack("MSBuild.Sdk.CMake.slnproj");
foreach(var pkgname in new []{ "MSBuild.Sdk.CMake.Template.Console", "MSBuild.Sdk.CMake.Template.Library" })
{
string processName;
ProcessArgumentBuilder args;
if(Environment.OSVersion.Platform == PlatformID.Unix)
{
processName = "mono";
args = new ProcessArgumentBuilder().Append(
DirectoryPath.FromString("buildtools").CombineWithFilePath("nuget.exe").ToString())
.Append("pack")
.Append(
DirectoryPath.FromString("templates").Combine(pkgname).CombineWithFilePath($"{pkgname}.nuspec").ToString()
)
.Append("-OutputDirectory")
.Append("nupkg")
;
}
else
{
processName = DirectoryPath.FromString("buildtools").CombineWithFilePath("nuget.exe").ToString();
args = new ProcessArgumentBuilder()
.Append("pack")
.Append(
DirectoryPath.FromString("templates").Combine(pkgname).CombineWithFilePath($"{pkgname}.nuspec").ToString()
)
.Append("-OutputDirectory")
.Append("nupkg")
;
}
var exitCode = StartProcess(processName, new ProcessSettings(){ Arguments = args });
if(exitCode != 0)
{
throw new Exception($"failed to execute nuget pack({exitCode})");
}
}
});
RunTarget(target);