-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAddLocalNugetSourceModule.cs
More file actions
35 lines (31 loc) · 1.35 KB
/
Copy pathAddLocalNugetSourceModule.cs
File metadata and controls
35 lines (31 loc) · 1.35 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
using ModularPipelines.Attributes;
using ModularPipelines.Configuration;
using ModularPipelines.Context;
using ModularPipelines.DotNet.Extensions;
using ModularPipelines.DotNet.Options;
using ModularPipelines.Exceptions;
using ModularPipelines.Models;
using ModularPipelines.Modules;
namespace EnumerableAsyncProcessor.Pipeline.Modules.LocalMachine;
[DependsOn<CreateLocalNugetFolderModule>]
public class AddLocalNugetSourceModule : Module<CommandResult>
{
protected override ModuleConfiguration Configure()
{
return ModuleConfiguration.Create()
.WithIgnoreFailuresWhen((_, exception) =>
exception is CommandException commandException &&
commandException.StandardOutput.Contains("The name specified has already been added to the list of available package sources"))
.Build();
}
protected override async Task<CommandResult?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
{
var localNugetPathResult = await context.GetModule<CreateLocalNugetFolderModule>();
return await context.DotNet().Nuget.Add
.Source(new DotNetNugetAddSourceOptions
{
Packagesourcepath = localNugetPathResult.ValueOrDefault!.Path,
Name = "ModularPipelinesLocalNuGet"
}, cancellationToken: cancellationToken);
}
}