|
| 1 | +using ModularPipelines.Context; |
| 2 | +using ModularPipelines.DotNet.Extensions; |
| 3 | +using ModularPipelines.DotNet.Options; |
| 4 | +using ModularPipelines.Git.Extensions; |
| 5 | +using ModularPipelines.Models; |
| 6 | +using ModularPipelines.Modules; |
| 7 | +using ModularPipelines.Options; |
| 8 | + |
| 9 | +namespace EnumerableAsyncProcessor.Pipeline.Modules; |
| 10 | + |
| 11 | +public class BuildBenchmarkProjectsModule : Module<List<CommandResult>> |
| 12 | +{ |
| 13 | + protected override async Task<List<CommandResult>?> ExecuteAsync( |
| 14 | + IModuleContext context, |
| 15 | + CancellationToken cancellationToken) |
| 16 | + { |
| 17 | + var results = new List<CommandResult>(); |
| 18 | + var executionOptions = new CommandExecutionOptions |
| 19 | + { |
| 20 | + ThrowOnNonZeroExitCode = true, |
| 21 | + }; |
| 22 | + |
| 23 | + foreach (var benchmarkProjectFile in context |
| 24 | + .Git().RootDirectory |
| 25 | + .GetFiles(file => file.Path.EndsWith(".csproj", StringComparison.OrdinalIgnoreCase) |
| 26 | + && file.Path.Contains("Benchmarks", StringComparison.OrdinalIgnoreCase))) |
| 27 | + { |
| 28 | + results.Add(await context.DotNet().Build(new DotNetBuildOptions |
| 29 | + { |
| 30 | + ProjectSolution = benchmarkProjectFile.Path, |
| 31 | + Configuration = "Release", |
| 32 | + }, executionOptions: executionOptions, cancellationToken: cancellationToken).ConfigureAwait(false)); |
| 33 | + } |
| 34 | + |
| 35 | + return results; |
| 36 | + } |
| 37 | +} |
0 commit comments