-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.cake
105 lines (87 loc) · 2.92 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
#tool nuget:?package=vswhere
var target = Argument("target", "Default");
const string targetProject = "./RunOnMainThread.sln";
const string nuspecFile = "./RunOnMainThread.nuspec";
var apiKey = EnvironmentVariable("NUGET_API_KEY");
var msBuildPath = findMSBuildPath();
var packSettings = new NuGetPackSettings();
var buildSettings = new MSBuildSettings
{
ToolPath = msBuildPath,
Verbosity = Verbosity.Verbose,
Configuration = "Release"
};
var publishSettings = new NuGetPushSettings
{
ApiKey = apiKey,
Source = "https://www.nuget.org/api/v2/package",
};
private FilePath findMSBuildPath()
{
FilePath msBuildPath = null;
if (IsRunningOnWindows())
{
var vsLatest = VSWhereLatest(new VSWhereLatestSettings
{
IncludePrerelease = true,
Requires = "Component.Xamarin"
});
if (vsLatest != null)
{
msBuildPath = vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/MSBuild.exe");
}
}
return msBuildPath;
}
Task("Clean")
.Does(() =>
{
CleanDirectory("./bin");
CleanDirectory("./build");
CleanDirectory("./packages");
CleanDirectory("./RunOnMainThread/bin");
CleanDirectory("./RunOnMainThread/obj");
CleanDirectory("./RunOnMainThread.Fody/bin");
CleanDirectory("./RunOnMainThread.Fody/obj");
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() => NuGetRestore(targetProject));
Task("Build")
.IsDependentOn("Restore")
.Does(() => MSBuild(targetProject, buildSettings));
Task("Copy")
.IsDependentOn("Build")
.Does(() =>
{
EnsureDirectoryExists("build/netclassicweaver");
EnsureDirectoryExists("build/netstandardweaver");
var targets = new [] { "netstandard2.0", "MonoAndroid81", "Xamarin.iOS10", "Xamarin.Mac20", "Xamarin.TvOS10", "Xamarin.WatchOS10" };
foreach(var target in targets)
{
EnsureDirectoryExists($"build/lib/{target}");
CopyFiles($@"bin\Release\{target.ToLower()}\RunOnMainThread.dll", $@"build\lib\{target}");
}
//Weavers
CopyFiles(@"bin\Release\net46\RunOnMainThread.Fody.dll", @"build\netclassicweaver");
CopyFiles(@"bin\Release\net46\RunOnMainThread.Fody.pdb", @"build\netclassicweaver");
CopyFiles(@"bin\Release\netstandard2.0\RunOnMainThread.Fody.dll", @"build\netstandardweaver");
CopyFiles(@"bin\Release\netstandard2.0\RunOnMainThread.Fody.pdb", @"build\netstandardweaver");
});
Task("Pack")
.IsDependentOn("Copy")
.Does(() => NuGetPack(nuspecFile, packSettings));
Task("Publish")
.IsDependentOn("Pack")
.Does(() =>
{
try
{
NuGetPush(GetFiles("*.nupkg").First().FullPath, publishSettings);
}
catch(CakeException) { /* Swallow exception if package already exists */}
});
//Default Operation
Task("Default")
.IsDependentOn("Pack");
RunTarget(target);