Essentials/build.cake

101 строка
2.5 KiB
Plaintext
Исходник Постоянная ссылка Обычный вид История

2023-04-19 16:02:45 +03:00
#addin "nuget:?package=Cake.Boots&version=1.1.0.712-preview2"
2023-04-19 15:36:42 +03:00
2020-09-04 04:40:58 +03:00
var TARGET = Argument("t", Argument("target", "ci"));
var NUGET_VERSION = EnvironmentVariable("NUGET_VERSION") ?? "1.0.0";
var GIT_SHA = Argument("gitSha", EnvironmentVariable("GIT_SHA") ?? "");
var GIT_BRANCH_NAME = Argument("gitBranch", EnvironmentVariable("GIT_BRANCH_NAME") ?? "");
Task("prepare")
2023-04-19 16:08:15 +03:00
.Does(async () =>
2020-09-04 04:40:58 +03:00
{
2023-04-19 15:36:42 +03:00
// Setup latest Xamarin.Android SDK
await Boots (Product.XamarinAndroid, ReleaseChannel.Stable);
2020-09-04 04:40:58 +03:00
// Update .csproj nuget versions
XmlPoke("./Xamarin.Essentials/Xamarin.Essentials.csproj", "/Project/PropertyGroup/PackageVersion", NUGET_VERSION);
});
Task("libs")
.IsDependentOn("prepare")
.Does(() =>
{
MSBuild("./Xamarin.Essentials/Xamarin.Essentials.csproj", new MSBuildSettings()
.EnableBinaryLogger("./output/binlogs/libs.binlog")
.SetConfiguration("Release")
.WithRestore());
});
Task("nugets")
.IsDependentOn("prepare")
.IsDependentOn("libs")
.IsDependentOn("docs")
.Does(() =>
{
MSBuild("./Xamarin.Essentials/Xamarin.Essentials.csproj", new MSBuildSettings()
.EnableBinaryLogger("./output/binlogs/nugets.binlog")
.SetConfiguration("Release")
.WithRestore()
.WithProperty("PackageOutputPath", MakeAbsolute(new FilePath("./output/")).FullPath)
.WithTarget("Pack"));
});
Task("tests")
.IsDependentOn("libs")
.Does(() =>
{
var failed = 0;
foreach (var csproj in GetFiles("./Tests/**/*.csproj")) {
try {
DotNetTest(csproj.FullPath, new DotNetTestSettings {
2020-09-04 04:40:58 +03:00
Configuration = "Release",
2023-04-19 15:49:47 +03:00
Loggers = new [] { $"trx;LogFileName={csproj.GetFilenameWithoutExtension()}.trx" }
2020-09-04 04:40:58 +03:00
});
} catch (Exception) {
failed++;
}
}
var output = $"./output/test-results/";
EnsureDirectoryExists(output);
CopyFiles($"./tests/**/TestResults/*.trx", output);
if (failed > 0)
throw new Exception($"{failed} tests have failed.");
});
Task("samples")
.IsDependentOn("nugets")
.Does(() =>
{
MSBuild("./Xamarin.Essentials.sln", new MSBuildSettings()
.EnableBinaryLogger("./output/binlogs/samples.binlog")
.SetConfiguration("Release")
.WithRestore());
});
Task("docs")
.IsDependentOn("libs")
.WithCriteria(IsRunningOnWindows())
.Does(() =>
{
MSBuild("./Xamarin.Essentials/Xamarin.Essentials.csproj", new MSBuildSettings()
.EnableBinaryLogger("./output/binlogs/docs.binlog")
2020-09-04 04:40:58 +03:00
.SetConfiguration("Release")
.WithRestore()
.WithTarget("mdocupdatedocs"));
});
Task("ci")
.IsDependentOn("libs")
.IsDependentOn("nugets")
.IsDependentOn("tests")
.IsDependentOn("samples");
2022-03-04 17:02:54 +03:00
Task("ci-release")
.IsDependentOn("libs")
2022-03-04 17:06:39 +03:00
.IsDependentOn("nugets");
2022-03-04 17:02:54 +03:00
2020-09-04 04:40:58 +03:00
RunTarget(TARGET);