-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.csx
52 lines (40 loc) · 1.6 KB
/
build.csx
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
#!/usr/bin/env dotnet-script
#r "nuget:SimpleTasks, 0.9.4"
using SimpleTasks;
using static SimpleTasks.SimpleTask;
#nullable enable
string libDir = "src/PropertyChanged.SourceGenerator";
string testsDir = "src/PropertyChanged.SourceGenerator.UnitTests";
string nugetDir = "NuGet";
string CommonFlags(string? version, string? configuration) =>
$"--configuration={configuration ?? "Release"} -p:VersionPrefix=\"{version ?? "0.0.0"}\"";
CreateTask("build").Run((string versionOpt, string configurationOpt) =>
{
var flags = CommonFlags(versionOpt, configurationOpt);
Command.Run("dotnet", $"build {flags} \"{libDir}\"");
});
CreateTask("package").DependsOn("build").Run((string version, string configurationOpt) =>
{
var flags = CommonFlags(version, configurationOpt) + $" --no-build --output=\"{nugetDir}\"";
Command.Run("dotnet", $"pack {flags} \"{libDir}\"");
});
CreateTask("test").Run(() =>
{
Command.Run("dotnet", $"test \"{testsDir}\"");
});
CreateTask("coverage").Run(() =>
{
Command.Run("dotnet", $"test -p:AltCover=true {testsDir}");
Command.Run("dotnet", $"reportgenerator -reports:{testsDir}/coverage.xml -targetdir:coverage -assemblyfilters:+PropertyChanged.SourceGenerator");
});
CreateTask("accept-tests").Run(() =>
{
var files = Directory.GetFiles(testsDir, "*.received.cs", SearchOption.AllDirectories);
foreach (var file in files)
{
var renamed = System.Text.RegularExpressions.Regex.Replace(file, @"\.received\.cs$", ".verified.cs");
Console.WriteLine($"{file} -> {renamed}");
File.Move(file, renamed, true);
}
});
return InvokeTask(Args);