|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.IO; |
4 | | -using System.Threading.Tasks; |
5 | 4 | using GlobExpressions; |
6 | 5 | using static Bullseye.Targets; |
7 | 6 | using static SimpleExec.Command; |
8 | 7 |
|
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"; |
16 | 13 |
|
17 | | - static async Task Main(string[] args) |
| 14 | +Target(Clean, |
| 15 | + ForEach("publish", "**/bin", "**/obj"), |
| 16 | + dir => |
18 | 17 | { |
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)) |
22 | 26 | { |
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 | + } |
27 | 31 |
|
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 | + }); |
36 | 37 |
|
37 | | - foreach (var d in GetDirectories(dir)) |
38 | | - { |
39 | | - RemoveDirectory(d); |
40 | | - } |
41 | | - }); |
42 | 38 |
|
| 39 | +Target(Format, () => |
| 40 | +{ |
| 41 | + Run("dotnet", "tool restore"); |
| 42 | + Run("dotnet", "format --check"); |
| 43 | +}); |
43 | 44 |
|
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")); |
49 | 46 |
|
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 | + } |
51 | 54 |
|
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 | + }); |
59 | 60 |
|
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 | + }); |
65 | 68 |
|
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); |
73 | 71 |
|
74 | | - Target("default", DependsOn(Publish), () => Console.WriteLine("Done!")); |
75 | | - await RunTargetsAndExitAsync(args); |
76 | | - } |
77 | | -} |
0 commit comments