Adding Pipelines

By default the bootstrapper will automatically add all pipelines by type in the entry assembly via reflection, but you can also use it to add or define new pipelines.

It contains several methods to add additional pipelines by either type or as an instance:

  • AddPipeline<TPipeline>() will add a pipeline by type.
  • AddPipeline(IPipeline) and various overloads will add a pipeline instance.

Finding Pipelines By Reflection

The bootstrapper also includes the ability to use reflection to find and add pipeline types:

  • AddPipelines() will add all pipelines defined in the entry assembly.
  • AddPipelines(Assembly) will add all pipelines defined in the specified assembly.
  • AddPipelines(Type) will add all pipelines defined as nested classes in the specified parent type.
  • AddPipelines<TParent>() will add all pipelines defined as nested classes in the specified parent type.

Typically, the name of the added pipeline is inferred from the class name though its also possible to specify an alternate name.

Adding Directly

You can add pipelines to the IPipelineCollection directly using the following extensions:

  • AddPipelines(Action<IPipelineCollection>)
  • AddPipelines(Action<IReadOnlyConfigurationSettings, IPipelineCollection>)

Defining Pipelines

In addition to adding pipelines defined as classes, the bootstrapper also has a robust set of extensions for directly defining pipelines:

  • AddPipeline(...) overloads will directly define a pipeline.
  • AddSerialPipeline(...) overloads will directly define a pipeline that has dependencies on all other currently defined pipelines.
  • AddIsolatedPipeline(...) overloads will directly define an isolated pipeline.
  • AddDeploymentPipeline(...) overloads will directly define a deployment pipeline.

Each of these methods have overloads that allow you to:

Pipeline Builder

The bootstrapper also provides a fluent API specifically for defining pipelines using a "builder" style:

  • BuildPipeline(string, Action<PipelineBuilder>) specifies a pipeline name and a delegate that uses a new PipelineBuilder.

The PipelineBuilder includes a number of fluent methods for defining different parts of your pipeline:

To complete building the pipeline call Build():

using System;
using System.Threading.Tasks;
using Statiq.App;
using Statiq.Markdown;

namespace MyGenerator
{
  public class Program
  {
    public static async Task<int> Main(string[] args) =>
      await Bootstrapper
        .Factory
        .CreateDefault(args)
        .BuildPipeline("Render Markdown", builder => builder
            .WithInputReadFiles("*.md")
            .WithProcessModules(new RenderMarkdown())
            .WithOutputWriteFiles(".html"))
        .RunAsync();
  }
}