Interface IAtomLifecycleHook
- Namespace
- Invex.Atom.Build
- Assembly
- Invex.Atom.Build.dll
Defines a hook that can participate in the Atom build lifecycle.
public interface IAtomLifecycleHook
Examples
public class MyLifecycleHook : IAtomLifecycleHook
{
public Task BeforeExecute(CancellationToken cancellationToken)
{
// Check preconditions before targets are executed
return Task.CompletedTask;
}
}
Remarks
Implementations of this interface can be registered in the dependency injection container to receive callbacks at specific points in the Atom build lifecycle. Multiple hooks can be registered and will be invoked in registration order.
All methods have default no-op implementations, so implementers only need to override the methods they are interested in.
Methods
AfterExecute(CancellationToken)
Called after all build targets have completed execution (regardless of success or failure).
Task AfterExecute(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task
A task representing the asynchronous operation.
Remarks
This hook is called in a finally-like manner, allowing modules to perform cleanup or post-execution processing.
BeforeExecute(CancellationToken)
Called after the build model has been resolved and before build targets are executed.
Task BeforeExecute(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task
A task representing the asynchronous operation.
Remarks
This is an ideal point for modules to perform validation or generate files that must be up-to-date before the build proceeds (e.g., workflow generation checks). Throwing an exception from this method will prevent the build from executing.