PipelineOutputDiffingExtensions Methods
ClassMethods4 members
Extensions for detecting stale generated pipeline output.
WithOutputDiffing(IDistributedApplicationBuilder, string, string?, string?) Section titled WithOutputDiffing(IDistributedApplicationBuilder, string, string?, string?)extensionI Adds an opt-in target that checks for stale generated pipeline output.
public static class PipelineOutputDiffingExtensions{ public static IDistributedApplicationBuilder WithOutputDiffing( this IDistributedApplicationBuilder builder, string targetStep = "publish", string? diffStepName = null, string? description = null) { // ... }}Parameters
targetStep stringoptionalThe step whose completed output is compared. Defaults to publish.diffStepName string?optionalThe comparison target name. When null, uses the target name followed by -and-diff .descriptionstring?optionalAn optional description of the comparison target.Returns
IDistributedApplicationBuilder The IDistributedApplicationBuilder for chaining.Exceptions
ArgumentNullExceptionbuilder or targetStep is null.ArgumentExceptiontargetStep or diffStepName is empty.Examples
builder.WithOutputDiffing();// Run: aspire do publish-and-diffWithOutputDiffing(IDistributedApplicationBuilder, Func<PipelineStep>) Section titled WithOutputDiffing(IDistributedApplicationBuilder, Func<PipelineStep>)extensionI Adds an opt-in target that checks for stale generated pipeline output.
public static class PipelineOutputDiffingExtensions{ public static IDistributedApplicationBuilder WithOutputDiffing( this IDistributedApplicationBuilder builder, Func<PipelineStep> createStep) { // ... }}Parameters
createStep Func<PipelineStep> A factory that constructs the comparison step, including its dependencies and action.Returns
IDistributedApplicationBuilder The IDistributedApplicationBuilder for chaining.Exceptions
ArgumentNullExceptionbuilder or createStep is null.Remarks
The check compares existing output with artifacts regenerated from the current source and fails if selected output differs. Capture runs only when the comparison target is selected, directly or through another target's dependencies. The baseline captures before every selected step so prerequisite and build writes are checked. The comparison step's dependencies and action finish before the second capture and comparison. Each capture resolves the global output directory; generators should write checked artifacts beneath it. This boundary does not enforce where writes occur. Step factories and configuration callbacks run before the baseline and must not write checked artifacts. Final actions appended to the comparison step after registration and AfterPublishEvent run too late for their writes to be checked.
Examples
builder.WithOutputDiffing(() => new PipelineStep{ Name = "check-generated-files", DependsOnSteps = [WellKnownPipelineSteps.Publish], Tags = ["ci"], Action = _ => Task.CompletedTask});// Run: aspire do check-generated-filesWithOutputDiffing(IDistributedApplicationBuilder, string, string?, string?) Section titled WithOutputDiffing(IDistributedApplicationBuilder, string, string?, string?)extensionI Adds an opt-in target using a typed snapshotter and comparer.
public static class PipelineOutputDiffingExtensions{ public static IDistributedApplicationBuilder WithOutputDiffing<TSnapshot, TSnapshotter, TComparer>( this IDistributedApplicationBuilder builder, string targetStep = "publish", string? diffStepName = null, string? description = null) { // ... }}Parameters
targetStep stringoptionalThe step whose completed output is compared. Defaults to publish.diffStepName string?optionalThe comparison target name. When null, uses the target name followed by -and-diff .descriptionstring?optionalAn optional description of the comparison target.Returns
IDistributedApplicationBuilder The IDistributedApplicationBuilder for chaining.Exceptions
ArgumentNullExceptionbuilder or targetStep is null.ArgumentExceptiontargetStep or diffStepName is empty.Examples
builder.WithOutputDiffing<DeploymentSnapshot, DeploymentSnapshotter, DeploymentComparer>();WithOutputDiffing(IDistributedApplicationBuilder, Func<PipelineStep>) Section titled WithOutputDiffing(IDistributedApplicationBuilder, Func<PipelineStep>)extensionI Adds an opt-in target using a typed snapshotter and comparer.
public static class PipelineOutputDiffingExtensions{ public static IDistributedApplicationBuilder WithOutputDiffing<TSnapshot, TSnapshotter, TComparer>( this IDistributedApplicationBuilder builder, Func<PipelineStep> createStep) { // ... }}Parameters
createStep Func<PipelineStep> A factory that constructs the comparison step, including its dependencies and action.Returns
IDistributedApplicationBuilder The IDistributedApplicationBuilder for chaining.Exceptions
ArgumentNullExceptionbuilder or createStep is null.ArgumentExceptiontargetStep or diffStepName is empty.Remarks
The snapshotter and comparer are registered as transient defaults for
TSnapshot . Existing registrations for either closed generic interface are preserved. Each capture resolves its snapshotter. A comparer is resolved after the second capture. Examples
builder.WithOutputDiffing();// Run: aspire do publish-and-diff