-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathUploadPackagesToLocalNuGetModule.cs
More file actions
44 lines (38 loc) · 1.71 KB
/
Copy pathUploadPackagesToLocalNuGetModule.cs
File metadata and controls
44 lines (38 loc) · 1.71 KB
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
using EnumerableAsyncProcessor.Extensions;
using Microsoft.Extensions.Logging;
using ModularPipelines.Attributes;
using ModularPipelines.Context;
using ModularPipelines.DotNet.Extensions;
using ModularPipelines.DotNet.Options;
using ModularPipelines.Models;
using ModularPipelines.Modules;
namespace EnumerableAsyncProcessor.Pipeline.Modules.LocalMachine;
[DependsOn<AddLocalNugetSourceModule>]
[DependsOn<PackagePathsParserModule>]
[DependsOn<CreateLocalNugetFolderModule>]
public class UploadPackagesToLocalNuGetModule : Module<CommandResult[]>
{
protected override async Task OnBeforeExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
{
var packagePaths = await context.GetModule<PackagePathsParserModule>();
foreach (var packagePath in packagePaths.ValueOrDefault ?? [])
{
context.Logger.LogInformation("[Local Directory] Uploading {File}", packagePath);
}
await base.OnBeforeExecuteAsync(context, cancellationToken);
}
protected override async Task<CommandResult[]?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
{
var localRepoLocation = await context.GetModule<CreateLocalNugetFolderModule>();
var packagePaths = await context.GetModule<PackagePathsParserModule>();
return await packagePaths.ValueOrDefault!
.SelectAsync(file => context.DotNet()
.Nuget
.Push(new DotNetNugetPushOptions
{
Path = file.Path,
Source = localRepoLocation.ValueOrDefault!.Path,
}, cancellationToken: cancellationToken), cancellationToken: cancellationToken)
.ProcessOneAtATime();
}
}