forked from canton7/RestEase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.csx
53 lines (43 loc) · 2.01 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
53
#!/usr/bin/env dotnet-script
#r "nuget: SimpleTasks, 0.9.4"
using SimpleTasks;
using static SimpleTasks.SimpleTask;
#nullable enable
string restEaseDir = "src/RestEase";
string httpClientFactoryDir = "src/RestEase.HttpClientFactory";
string sourceGeneratorDir = "src/RestEase.SourceGenerator";
string testsDir = "src/RestEase.UnitTests";
string httpClientFactoryTestsDir = "src/RestEase.HttpClientFactory.UnitTests";
string sourceGeneratorTestsDir = "src/RestEase.SourceGenerator.UnitTests";
CreateTask("build").Run((string versionOpt, string configurationOpt, bool updateCompatSuppression) =>
{
// We can't have separate build and package steps due to https://github.com/dotnet/sdk/issues/24943
// We can't run package validation on every build, as it needs a version higher than the baseline (so not 0.0.0)
// We therefore package on every build (<GeneratePackageOnBuild>true</GeneratePackageOnBuild>), and only turn on package validation when we
// specify a version.
string flags = $"--configuration={configurationOpt ?? "Release"} -p:VersionPrefix=\"{versionOpt ?? "0.0.0"}\"";
string validationFlags = "";
if (versionOpt != null)
{
flags += " -p:GeneratePackageOnBuild=true";
validationFlags = "-p:EnablePackageValidation=true";
if (updateCompatSuppression)
{
validationFlags += " -p:GenerateCompatibilitySuppressionFile=true";
}
}
else if (updateCompatSuppression)
{
throw new Exception("--updateCompatSuppression requires --version");
}
Command.Run("dotnet", $"build {flags} {validationFlags} \"{restEaseDir}\"");
Command.Run("dotnet", $"build {flags} {validationFlags} \"{httpClientFactoryDir}\"");
Command.Run("dotnet", $"build {flags} \"{sourceGeneratorDir}\"");
});
CreateTask("test").Run(() =>
{
Command.Run("dotnet", $"test \"{testsDir}\"");
Command.Run("dotnet", $"test \"{httpClientFactoryTestsDir}\"");
Command.Run("dotnet", $"test \"{sourceGeneratorTestsDir}\"");
});
return InvokeTask(Args);