RequiredCommandResourceExtensions Methods
ClassMethods2 members
Provides extension methods for adding required command annotations to resources.
WithRequiredCommand(IResourceBuilder<T>, string, string?)Section titled WithRequiredCommand(IResourceBuilder<T>, string, string?)extensionIResourceBuilder<T> Declares that a resource requires a specific command/executable to be available on the local machine PATH before it can start.
public static class RequiredCommandResourceExtensions{ public static IResourceBuilder<T> WithRequiredCommand<T>( this IResourceBuilder<T> builder, string command, string? helpLink = null) { // ... }}Parameters
builderIResourceBuilder<T>The resource builder.commandstringThe command string (file name or path) that should be validated.helpLinkstring?optionalAn optional help link URL to guide users when the command is missing.Returns
IResourceBuilder<T>The resource builder.Remarks
The command is considered valid if either: 1. It is an absolute or relative path (contains a directory separator) that points to an existing file, or 2. It is discoverable on the current process PATH (respecting PATHEXT on Windows). If the command is not found, a warning message will be logged but the resource will be allowed to attempt to start.
WithRequiredCommand(IResourceBuilder<T>, string, Func<RequiredCommandValidationContext, Task<RequiredCommandValidationResult>>, string?)Section titled WithRequiredCommand(IResourceBuilder<T>, string, Func<RequiredCommandValidationContext, Task<RequiredCommandValidationResult>>, string?)extensionIResourceBuilder<T> Declares that a resource requires a specific command/executable to be available on the local machine PATH before it can start, with custom validation logic.
public static class RequiredCommandResourceExtensions{ public static IResourceBuilder<T> WithRequiredCommand<T>( this IResourceBuilder<T> builder, string command, Func<RequiredCommandValidationContext, Task<RequiredCommandValidationResult>> validationCallback, string? helpLink = null) { // ... }}Parameters
builderIResourceBuilder<T>The resource builder.commandstringThe command string (file name or path) that should be validated.validationCallbackFunc<RequiredCommandValidationContext, Task<RequiredCommandValidationResult>>A callback that validates the resolved command path. Receives a RequiredCommandValidationContext and returns a RequiredCommandValidationResult.helpLinkstring?optionalAn optional help link URL to guide users when the command is missing or fails validation.Returns
IResourceBuilder<T>The resource builder.Remarks
The command is first resolved to a full path. If found, the validation callback is invoked with the context containing the resolved path and service provider. The callback should return a
RequiredCommandValidationResult indicating whether the command is valid, which can be created via RequiredCommandValidationContext.Success or RequiredCommandValidationContext.Failure. If the command is not found or fails validation, a warning message will be logged but the resource will be allowed to attempt to start.