2023-02-09 23:19:42 +01:00
#addin nuget:?package=Cake.DocFx&version=1.0.0
2024-04-05 10:54:39 +02:00
#tool dotnet:?package=docfx&version=2.75.3
2020-05-21 22:50:38 +02:00
2020-05-25 22:52:35 +02:00
// this is the upcoming version, for prereleases
2024-09-02 21:00:40 +02:00
var version = Argument("version", "7.1.1");
2020-05-21 22:50:38 +02:00
var target = Argument("target", "Default");
2024-04-05 10:51:12 +02:00
var gitRef = Argument("ref", "refs/heads/main");
var buildNum = Argument("buildNum", "");
2020-05-21 22:50:38 +02:00
var config = Argument("configuration", "Release");
2023-06-09 12:59:12 +02:00
var serve = HasArgument("serve");
2020-05-21 22:50:38 +02:00
Task("Prepare").Does(() => {
2023-07-10 14:35:47 +02:00
DotNetWorkloadInstall("android");
2024-04-05 10:51:12 +02:00
2022-09-14 22:00:45 +02:00
DotNetRestore("MLEM.sln");
DotNetRestore("MLEM.FNA.sln");
2024-09-02 19:55:28 +02:00
DotNetRestore("MLEM.KNI.sln");
2022-06-24 14:01:26 +02:00
2024-04-05 10:51:12 +02:00
if (!gitRef.StartsWith("refs/tags/") && !string.IsNullOrEmpty(buildNum)) {
Information($"Appending {buildNum} to version");
version += $"-ci.{buildNum}";
2020-05-21 22:50:38 +02:00
}
2022-06-24 14:01:26 +02:00
2022-09-09 17:55:14 +02:00
DeleteFiles("**/MLEM*.nupkg");
2020-05-21 22:50:38 +02:00
});
Task("Build").IsDependentOn("Prepare").Does(() =>{
2022-09-14 22:00:45 +02:00
var settings = new DotNetBuildSettings {
2020-05-21 22:50:38 +02:00
Configuration = config,
2023-11-22 21:56:27 +01:00
ArgumentCustomization = args => args.Append($"/p:Version={version}"),
// .net 8 has an issue that causes simultaneous tool restores during build to fail
MSBuildSettings = new DotNetMSBuildSettings { MaxCpuCount = 1 }
2020-05-21 22:50:38 +02:00
};
2022-09-14 22:00:45 +02:00
DotNetBuild("MLEM.sln", settings);
DotNetBuild("MLEM.FNA.sln", settings);
2024-09-02 19:55:28 +02:00
DotNetBuild("MLEM.KNI.sln", settings);
2020-05-21 22:50:38 +02:00
});
2021-03-18 17:28:08 +01:00
Task("Test").IsDependentOn("Build").Does(() => {
2022-09-14 22:00:45 +02:00
var settings = new DotNetTestSettings {
2021-03-18 17:28:08 +01:00
Configuration = config,
2023-11-23 10:26:58 +01:00
Collectors = {"XPlat Code Coverage"},
Loggers = {"console;verbosity=normal"}
2022-06-24 14:01:26 +02:00
};
2022-09-14 23:44:07 +02:00
DotNetTest("MLEM.sln", settings);
DotNetTest("MLEM.FNA.sln", settings);
2024-09-02 19:55:28 +02:00
DotNetTest("MLEM.KNI.sln", settings);
2021-03-18 17:28:08 +01:00
});
Task("Pack").IsDependentOn("Test").Does(() => {
2022-09-14 22:00:45 +02:00
var settings = new DotNetPackSettings {
2020-05-21 22:50:38 +02:00
Configuration = config,
ArgumentCustomization = args => args.Append($"/p:Version={version}")
};
2022-09-15 10:44:50 +02:00
DotNetPack("MLEM.sln", settings);
DotNetPack("MLEM.FNA.sln", settings);
2024-09-02 19:55:28 +02:00
DotNetPack("MLEM.KNI.sln", settings);
2020-05-21 22:50:38 +02:00
});
2024-04-05 10:51:12 +02:00
Task("Push").WithCriteria(gitRef == "refs/heads/main" || gitRef.StartsWith("refs/tags/"), "Not on main branch or tag").IsDependentOn("Pack").Does(() => {
2024-01-14 22:12:07 +01:00
DotNetNuGetPushSettings settings;
2024-04-05 10:51:12 +02:00
if (gitRef.StartsWith("refs/tags/")) {
Information("Pushing to public feed");
2024-01-14 22:12:07 +01:00
settings = new DotNetNuGetPushSettings {
Source = "https://api.nuget.org/v3/index.json",
ApiKey = EnvironmentVariable("NUGET_KEY")
};
} else {
2024-04-05 10:51:12 +02:00
Information("Pushing to private feed");
2024-01-14 22:12:07 +01:00
settings = new DotNetNuGetPushSettings {
Source = "https://nuget.ellpeck.de/v3/index.json",
ApiKey = EnvironmentVariable("BAGET_KEY")
};
}
settings.SkipDuplicate = true;
DotNetNuGetPush("**/MLEM*.nupkg", settings);
2020-05-21 22:50:38 +02:00
});
2020-05-21 23:19:16 +02:00
Task("Document").Does(() => {
2023-06-09 12:59:12 +02:00
DocFxMetadata("Docs/docfx.json");
DocFxBuild("Docs/docfx.json");
if (serve)
DocFxServe("Docs/_site");
2020-05-21 23:19:16 +02:00
});
2020-05-21 22:50:38 +02:00
2024-09-14 11:37:06 +02:00
Task("PublishWeb").Does(() => {
DotNetPublish("Demos.Web/Demos.Web.KNI.csproj", new DotNetPublishSettings {
Configuration = config,
ArgumentCustomization = args => args.Append($"/p:Version={version}")
});
});
2020-05-21 22:50:38 +02:00
Task("Default").IsDependentOn("Pack");
2020-05-22 01:44:47 +02:00
Task("Publish").IsDependentOn("Push");
2020-05-21 22:50:38 +02:00
2022-06-24 14:01:26 +02:00
RunTarget(target);