MyTrout.Pipelines.Steps.IO.Files 4.1.0

dotnet add package MyTrout.Pipelines.Steps.IO.Files --version 4.1.0
                    
NuGet\Install-Package MyTrout.Pipelines.Steps.IO.Files -Version 4.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MyTrout.Pipelines.Steps.IO.Files" Version="4.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MyTrout.Pipelines.Steps.IO.Files" Version="4.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MyTrout.Pipelines.Steps.IO.Files" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MyTrout.Pipelines.Steps.IO.Files --version 4.1.0
                    
#r "nuget: MyTrout.Pipelines.Steps.IO.Files, 4.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=MyTrout.Pipelines.Steps.IO.Files&version=4.1.0
                    
Install MyTrout.Pipelines.Steps.IO.Files as a Cake Addin
#tool nuget:?package=MyTrout.Pipelines.Steps.IO.Files&version=4.1.0
                    
Install MyTrout.Pipelines.Steps.IO.Files as a Cake Tool

MyTrout.Pipelines.Steps.IO.Files

Build Status nuget GitHub stars GitHub forks License: MIT

Quality Gate Status Coverage Maintainability Rating Security Rating Vulnerabilities

Introduction

MyTrout.Pipelines.Steps.IO.Files provides Pipeline steps to read, write, delete, and move files on the file system.

MyTrout.Pipelines.Steps.IO.Files targets .NET 6.0 and .NET 7.0

Pipelines.Hosting runs the Pipeline in a Console Application using Generic Host.

List of Available Steps

Installing via NuGet

Install-Package MyTrout.Pipelines.Steps.IO.Files

Software dependencies

1. MyTrout.Pipelines 4.0.0 minimum.

All software dependencies listed above use the MIT License.

How do I use the steps in this library?

sample C# code


    using MyTrout.Pipelines;
    using MyTrout.Pipelines.Hosting;
    using MyTrout.Pipelines.Steps.Cryptography
    using System;
    using System.Linq;
    using System.Threading.Tasks;

    namespace MyTrout.Pipeline.Hosting.Samples
    {
        public class Program
        {
            public static async Task Main(string[] args)
            {

                var host = Host.CreateDefaultBuilder(args)
                                    .AddStepDependency<DeleteFileOptions>()
                                    .UsePipeline(builder => 
                                    {
                                        builder
                                        // The first step doesn't exist and  must be user-provided.
                                            .AddStep<LoadTargetFileNameStep>()
                                            .AddStep<DeleteFileStep>()
                                    })
                                    .Build();

                //
                // IMPORTANT NOTE FOR DEVELOPERS:
                // 
                // Use StartAsync() to allow the caller to review the PipelineContext after execution.
                //
                await host.StartAsync().ConfigureAwait(false);

                var context = host.Services.GetService<PipelineContext>();

                if(context.Errors.Any())
                {
                    // TODO: Errors have already been logged, do any special error processing here.
                }

                return 0;
            }
        }
    }
}

sample appsettings.json file

This configuration provides a base directory to prevent path traversal issues.

{
    "DeleteFileBaseDirectory": "C:\"
}

How do I use Pipelines.Hosting with different configurations for different instances of the same step.

If Step1 prints the Step1Options value with a trailing space to the Console when each step is called, then the following code will generate "Moe, Larry & Curly ".


    using MyTrout.Pipelines;
    using MyTrout.Pipelines.Hosting;
    using MyTrout.Pipelines.Steps.Cryptography
    using System;
    using System.Linq;
    using System.Threading.Tasks;

    namespace MyTrout.Pipeline.Hosting.Samples
    {
        public class Program
        {
            public static async Task Main(string[] args)
            {
                // IMPORTANT NOTE FOR DEVELOPERS !
                // 
                // Step Dependencies with context must be defined BEFORE UsePipelines() to load the dependencies correctly.
                //

                var host = Host.CreateDefaultBuilder(args)
                                    .UsePipeline(builder => 
                                    {
                                        builder
                                            .AddStep<LoadTheFirstMofeFileLocationsStep>()
                                            .AddStep<MoveFileStep, MoveFileOptions>("context-A")
                                            .AddStep<LoadTheSecondMoveFileLocationStep>()
                                            .AddStep<MoveFileStepStep, MoveFileOptions>("context-B")
                                            .AddStep<DoOtherActionsStep>()
                                    })
                                    .Build();
                
                // IMPORTANT NOTE FOR DEVELOPERS !
                // 
                // Use StartAsync() to allow the caller to review the PipelineContext after execution.
                //

                await host.StartAsync().ConfigureAwait(false);

                var context = host.Services.GetService<PipelineContext>();

                if(context.Errors.Any())
                {
                    // TODO: Errors have already been logged, do any special error processing here.
                }

                return 0;
            }
        }
    }
}

sample appsettings.json file

{
    "context-A": {
        "MoveSourceFileBaseDirectory": "C:\\source\\",
        "MoveTargetFileBaseDirectory: "D:\\source\\"
    },
    "context-B": {
        "MoveSourceFileBaseDirectory": "D:\\source\\",
        "MoveTargetFileBaseDirectory: "E:\\source\\"
    }
}

Build the software locally.

1. Clone the software from the Pipelines repository.
2. Build the software in Visual Studio 2019 to pull down all of the dependencies from nuget.org.
3. In Visual Studio, run all tests.  All of the should pass.
4. If you have Visual Studio Enterprise 2019, analyze the code coverage; it should be 100%.
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on MyTrout.Pipelines.Steps.IO.Files:

Package Downloads
MyTrout.Pipelines.Steps.IO.Command

Provides Pipeline steps run a command line utility.

MyTrout.Pipelines.Steps.IO.Directories

Provides Pipeline steps to create, delete, move, and rename directories and enumerate files in directories on the file system.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.1.0 564 12/6/2022
4.0.0 828 6/15/2022
3.2.0 473 4/28/2022
3.1.0 436 12/26/2021
3.0.0 526 6/30/2021
2.1.0 401 2/3/2021
2.0.2 388 1/23/2021
2.0.1 532 1/1/2021
1.0.0 507 8/20/2020
0.5.0-beta 362 7/23/2020
0.4.0-beta 406 7/17/2020
0.3.0-beta 382 7/17/2020
0.2.1-beta 403 6/27/2020