Skip to content

Commit c44ff49

Browse files
committed
Use top level statement for build
1 parent 3982f2a commit c44ff49

File tree

1 file changed

+52
-58
lines changed

1 file changed

+52
-58
lines changed

build/Program.cs

Lines changed: 52 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,71 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Threading.Tasks;
54
using GlobExpressions;
65
using static Bullseye.Targets;
76
using static SimpleExec.Command;
87

9-
public static class Program
10-
{
11-
private const string Clean = "clean";
12-
private const string Build = "build";
13-
private const string Test = "test";
14-
private const string Format = "format";
15-
private const string Publish = "publish";
8+
const string Clean = "clean";
9+
const string Build = "build";
10+
const string Test = "test";
11+
const string Format = "format";
12+
const string Publish = "publish";
1613

17-
static async Task Main(string[] args)
14+
Target(Clean,
15+
ForEach("publish", "**/bin", "**/obj"),
16+
dir =>
1817
{
19-
Target(Clean,
20-
ForEach("publish", "**/bin", "**/obj"),
21-
dir =>
18+
IEnumerable<string> GetDirectories(string d)
19+
{
20+
return Glob.Directories(".", d);
21+
}
22+
23+
void RemoveDirectory(string d)
24+
{
25+
if (Directory.Exists(d))
2226
{
23-
IEnumerable<string> GetDirectories(string d)
24-
{
25-
return Glob.Directories(".", d);
26-
}
27+
Console.WriteLine($"Cleaning {d}");
28+
Directory.Delete(d, true);
29+
}
30+
}
2731

28-
void RemoveDirectory(string d)
29-
{
30-
if (Directory.Exists(d))
31-
{
32-
Console.WriteLine($"Cleaning {d}");
33-
Directory.Delete(d, true);
34-
}
35-
}
32+
foreach (var d in GetDirectories(dir))
33+
{
34+
RemoveDirectory(d);
35+
}
36+
});
3637

37-
foreach (var d in GetDirectories(dir))
38-
{
39-
RemoveDirectory(d);
40-
}
41-
});
4238

39+
Target(Format, () =>
40+
{
41+
Run("dotnet", "tool restore");
42+
Run("dotnet", "format --check");
43+
});
4344

44-
Target(Format, () =>
45-
{
46-
Run("dotnet", "tool restore");
47-
Run("dotnet", "format --check");
48-
});
45+
Target(Build, DependsOn(Format), () => Run("dotnet", "build . -c Release"));
4946

50-
Target(Build, DependsOn(Format), () => Run("dotnet", "build . -c Release"));
47+
Target(Test, DependsOn(Build),
48+
() =>
49+
{
50+
IEnumerable<string> GetFiles(string d)
51+
{
52+
return Glob.Files(".", d);
53+
}
5154

52-
Target(Test, DependsOn(Build),
53-
() =>
54-
{
55-
IEnumerable<string> GetFiles(string d)
56-
{
57-
return Glob.Files(".", d);
58-
}
55+
foreach (var file in GetFiles("tests/**/*.csproj"))
56+
{
57+
Run("dotnet", $"test {file} -c Release --no-restore --no-build --verbosity=normal");
58+
}
59+
});
5960

60-
foreach (var file in GetFiles("tests/**/*.csproj"))
61-
{
62-
Run("dotnet", $"test {file} -c Release --no-restore --no-build --verbosity=normal");
63-
}
64-
});
61+
Target(Publish, DependsOn(Test),
62+
ForEach("src/Conduit"),
63+
project =>
64+
{
65+
Run("dotnet",
66+
$"publish {project} -c Release -f net5.0 -o ./publish --no-restore --no-build --verbosity=normal");
67+
});
6568

66-
Target(Publish, DependsOn(Test),
67-
ForEach("src/Conduit"),
68-
project =>
69-
{
70-
Run("dotnet",
71-
$"publish {project} -c Release -f net5.0 -o ./publish --no-restore --no-build --verbosity=normal");
72-
});
69+
Target("default", DependsOn(Publish), () => Console.WriteLine("Done!"));
70+
await RunTargetsAndExitAsync(args);
7371

74-
Target("default", DependsOn(Publish), () => Console.WriteLine("Done!"));
75-
await RunTargetsAndExitAsync(args);
76-
}
77-
}

0 commit comments

Comments
 (0)