Files
sharpcompress/build/Program.cs

96 lines
2.0 KiB
C#
Raw Normal View History

2022-12-20 15:06:44 +00:00
using System;
2020-05-24 09:00:27 +01:00
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using GlobExpressions;
using static Bullseye.Targets;
using static SimpleExec.Command;
const string Clean = "clean";
2023-03-21 13:41:36 +00:00
const string Restore = "restore";
const string Build = "build";
const string Test = "test";
2023-03-21 13:41:36 +00:00
const string Format = "format";
const string Publish = "publish";
2021-01-09 13:33:34 +00:00
2022-12-20 13:45:47 +00:00
Target(
Clean,
ForEach("**/bin", "**/obj"),
dir =>
{
IEnumerable<string> GetDirectories(string d)
{
return Glob.Directories(".", d);
}
2020-05-24 09:00:27 +01:00
2022-12-20 13:45:47 +00:00
void RemoveDirectory(string d)
{
if (Directory.Exists(d))
{
Console.WriteLine(d);
Directory.Delete(d, true);
}
}
2020-05-24 09:00:27 +01:00
2022-12-20 13:45:47 +00:00
foreach (var d in GetDirectories(dir))
{
RemoveDirectory(d);
}
}
);
2020-05-24 09:00:27 +01:00
2023-03-21 13:41:36 +00:00
Target(
Format,
() =>
{
2023-03-21 13:44:02 +00:00
Run("dotnet", "tool restore");
Run("dotnet", "csharpier --check .");
2023-03-21 13:41:36 +00:00
}
);
2023-03-21 13:44:02 +00:00
Target(Restore, DependsOn(Format), () => Run("dotnet", "restore"));
2023-03-21 13:41:36 +00:00
2022-12-20 13:45:47 +00:00
Target(
Build,
2023-03-21 13:41:36 +00:00
DependsOn(Restore),
2022-12-20 13:45:47 +00:00
() =>
{
2023-03-21 13:54:45 +00:00
Run("dotnet", "build src/SharpCompress/SharpCompress.csproj -c Release --no-restore");
2022-12-20 13:45:47 +00:00
}
);
2021-01-09 13:32:14 +00:00
2022-12-20 13:45:47 +00:00
Target(
Test,
DependsOn(Build),
ForEach("net7.0", "net462"),
framework =>
{
IEnumerable<string> GetFiles(string d)
{
return Glob.Files(".", d);
}
2020-05-24 09:00:27 +01:00
2022-12-20 13:45:47 +00:00
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && framework == "net462")
{
return;
}
2020-05-24 09:00:27 +01:00
2022-12-20 13:45:47 +00:00
foreach (var file in GetFiles("**/*.Test.csproj"))
{
2023-03-21 13:56:51 +00:00
Run("dotnet", $"test {file} -c Release -f {framework} --no-restore --verbosity=normal");
2022-12-20 13:45:47 +00:00
}
}
);
2020-05-24 09:00:27 +01:00
2022-12-20 13:45:47 +00:00
Target(
Publish,
DependsOn(Test),
() =>
{
Run("dotnet", "pack src/SharpCompress/SharpCompress.csproj -c Release -o artifacts/");
}
);
2020-05-24 09:00:27 +01:00
Target("default", DependsOn(Publish), () => Console.WriteLine("Done!"));
2021-01-09 13:33:34 +00:00
await RunTargetsAndExitAsync(args);