forked from jonathanpeppers/Xamarin.Forms.Mocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
128 lines (108 loc) · 3.68 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
#tool nuget:?package=NUnit.ConsoleRunner&version=3.8.0
#addin nuget:?package=Cake.Boots&version=1.0.4.600-preview1
// Input args
string target = Argument("target", "Default");
string configuration = Argument("configuration", "Release");
// Define vars
var dirs = new[]
{
Directory("./build"),
Directory("./Xamarin.Forms.Mocks/bin") + Directory(configuration),
Directory("./Xamarin.Forms.Mocks.Tests/bin") + Directory(configuration),
Directory("./Xamarin.Forms.Mocks.Xaml/bin") + Directory(configuration),
Directory("./Xamarin.Forms.Mocks/obj") + Directory(configuration),
Directory("./Xamarin.Forms.Mocks.Tests/obj") + Directory(configuration),
Directory("./Xamarin.Forms.Mocks.Xaml/obj") + Directory(configuration),
};
string sln = "./Xamarin.Forms.Mocks.sln";
string version = "4.7.0.1";
string suffix = "";
MSBuildSettings MSBuildSettings()
{
var settings = new MSBuildSettings { Configuration = configuration };
if (IsRunningOnWindows())
{
// Find MSBuild for Visual Studio 2019 and newer
DirectoryPath vsLatest = VSWhereLatest();
FilePath msBuildPath = vsLatest?.CombineWithFilePath("./MSBuild/Current/Bin/MSBuild.exe");
// Find MSBuild for Visual Studio 2017
if (msBuildPath != null && !FileExists(msBuildPath))
msBuildPath = vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/MSBuild.exe");
// Have we found MSBuild yet?
if (!FileExists(msBuildPath))
{
throw new Exception($"Failed to find MSBuild: {msBuildPath}");
}
Information("Building using MSBuild at " + msBuildPath);
settings.ToolPath = msBuildPath;
}
else
{
settings.ToolPath = Context.Tools.Resolve("msbuild");
}
return settings.WithRestore();
}
Task("Boots")
.Does(async () =>
{
if (!IsRunningOnWindows ()) {
await Boots (Product.Mono, ReleaseChannel.Stable);
await Boots (Product.XamariniOS, ReleaseChannel.Preview);
}
await Boots (Product.XamarinAndroid, ReleaseChannel.Preview);
});
Task("Clean")
.Does(() =>
{
foreach (var dir in dirs)
CleanDirectory(dir);
});
Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
MSBuild(sln, MSBuildSettings());
});
Task("NUnit")
.IsDependentOn("Build")
.Does(() =>
{
NUnit3(dirs[2] + File("./net461/Xamarin.Forms.Mocks.Tests.dll"));
});
Task("NuGet-Package")
.IsDependentOn("NUnit")
.Does(() =>
{
var settings = new NuGetPackSettings
{
Verbosity = NuGetVerbosity.Detailed,
Version = version + suffix,
Files = new []
{
new NuSpecContent { Source = dirs[1] + File("netstandard2.0/Xamarin.Forms.Core.UnitTests.dll"), Target = "lib/netstandard2.0" },
new NuSpecContent { Source = dirs[3] + File("netstandard2.0/Xamarin.Forms.Xaml.UnitTests.dll"), Target = "lib/netstandard2.0" },
},
OutputDirectory = dirs[0]
};
NuGetPack("./Xamarin.Forms.Mocks.nuspec", settings);
});
Task("NuGet-Push")
.Does(() =>
{
var apiKey = TransformTextFile ("./.nugetapikey").ToString();
NuGetPush("./build/Xamarin.Forms.Mocks." + version + suffix + ".nupkg", new NuGetPushSettings
{
Verbosity = NuGetVerbosity.Detailed,
Source = "nuget.org",
ApiKey = apiKey
});
});
Task("Default")
.IsDependentOn("NuGet-Package");
Task("AppVeyor")
.IsDependentOn("Boots")
.IsDependentOn("NuGet-Package");
Task("Travis")
.IsDependentOn("Boots")
.IsDependentOn("NUnit");
RunTarget(target);