Skip to content

JasperFx Options

JasperFxOptions is the central configuration class for JasperFx. It extends SystemPartBase and participates in the describe command output.

Registering Options

cs
public static void ConfigureOptions(IServiceCollection services)
{
    services.AddJasperFx(opts =>
    {
        // Register an environment check inline
        opts.RegisterEnvironmentCheck(
            "Database connectivity",
            async (sp, ct) =>
            {
                // Verify your database is accessible
                await Task.CompletedTask;
            });
    });
}

snippet source | anchor

Key Properties

PropertyTypeDefaultDescription
ActiveProfilestring"Development"The current application profile
RequiredFilesstring[][]Files that must exist at startup
RememberedApplicationAssemblyAssembly?nullOverride the detected application assembly

RequireFile

Tell JasperFx that a file path is required. This adds a file-exists check to environment tests:

csharp
opts.RequireFile("appsettings.json");

RegisterEnvironmentCheck

Register an inline environment check:

csharp
opts.RegisterEnvironmentCheck(
    "Redis is reachable",
    async (sp, ct) =>
    {
        // throw on failure
    });

Application Assembly Detection

JasperFx automatically detects the main application assembly for scanning. In test scenarios, you can override this:

csharp
JasperFxOptions.RememberedApplicationAssembly = typeof(MyApp).Assembly;

This is useful when test runners or IDEs change the entry assembly.

Next Steps

Released under the MIT License.