string OutputPath { get; }
Gets the path where exported files will be saved.
The RazorWire CLI is a command-line tool for managing RazorWire projects. Its primary feature is the ability to export a reactive RazorWire site into a static or hybrid directory for hosting on services like S3 or traditional web servers.
You can run the CLI directly using the dotnet run command from the project directory, or build it as a global tool.
dotnet run --project Web/ForgeTrust.Runnable.Web.RazorWire.Cli -- [command] [options]
exportExports a RazorWire application to a static directory.
Options:
-o|--output <path>: Output directory where the static files will be saved (default: dist).-r|--routes <path>: Optional path to a file containing seed routes to crawl.-u|--url <url>: Base URL of a running application used for crawling.-p|--project <path.csproj>: Path to a .NET project to run automatically and export.-d|--dll <path.dll>: Path to a .NET DLL to run automatically and export.--app-args <token>: Repeatable app-argument token to pass through when launching --project or --dll.--no-build: Project mode only. Skips the release publish step and reuses existing published output.Exactly one source option is required: --url, --project, or --dll.
When launched app processes are started by the CLI (--project or --dll), they run in production environment (DOTNET_ENVIRONMENT=Production, ASPNETCORE_ENVIRONMENT=Production).
When --project is used:
--no-build to skip publishing and reuse existing published output.When --dll is used:
For both --project and --dll:
--urls via --app-args, the CLI appends --urls http://127.0.0.1:0.Example:
dotnet run --project Web/ForgeTrust.Runnable.Web.RazorWire.Cli -- export -o ./dist -u http://localhost:5233
dotnet run --project Web/ForgeTrust.Runnable.Web.RazorWire.Cli -- export -o ./dist -p ./examples/razorwire-mvc/RazorWireWebExample.csproj
dotnet run --project Web/ForgeTrust.Runnable.Web.RazorWire.Cli -- export -o ./dist -d ./bin/Release/net10.0/MyApp.dll --app-args --urls --app-args http://127.0.0.1:5009
A terminal/CLI module for RazorWire providing static site export capabilities.
void ConfigureServices(StartupContext context, IServiceCollection services)
Configures services needed for the CLI, including the ExportEngine and enhanced console logging.
contextThe startup context.servicesThe service collection to populate.void ConfigureHostBeforeServices(StartupContext context, IHostBuilder builder)
Executes pre-service host configuration; currently no implementation is required.
contextThe startup context.builderThe host builder.void ConfigureHostAfterServices(StartupContext context, IHostBuilder builder)
Executes post-service host configuration; currently no implementation is required.
contextThe startup context.builderThe host builder.void RegisterDependentModules(ModuleDependencyBuilder builder)
Registers dependencies for this module; currently no implementation is required.
builderThe module dependency builder.Provides context and state for an export operation, including configuration and crawl progress.
string OutputPath { get; }
Gets the path where exported files will be saved.
string? SeedRoutesPath { get; }
Gets the optional path to a seed routes file.
string BaseUrl { get; }
Gets the base URL of the source application being exported.
HashSet<string> Visited { get; }
Gets the set of URLs that have already been visited during the crawl.
Queue<string> Queue { get; }
Gets the queue of URLs pending processing.
Represents a started or startable external target application process.
void Start()
Starts the process and begins asynchronous output capture.
bool HasExited { get; }
Gets a value indicating whether the process has exited.
Creates ITargetAppProcess instances for launch specifications.
ITargetAppProcess Create(ProcessLaunchSpec spec)
Creates a new process wrapper for the provided launch spec.
specThe process launch specification.A process wrapper ready to start.
Default ITargetAppProcessFactory implementation.
Creates validated export source requests from CLI options.
Describes how to launch an external process.
string FileName { get; init; }
Gets the executable file name.
IReadOnlyList<string> Arguments { get; init; }
Gets the argument tokens passed to the process.
IReadOnlyDictionary<string, string> EnvironmentOverrides { get; init; }
Gets environment variable overrides applied for process startup.
string WorkingDirectory { get; init; }
Gets the working directory for the process.
Resolves export sources and, when needed, orchestrates launching a target application for crawling.
TimeSpan ListeningUrlTimeout { get; set; }
Gets or sets the maximum time to wait for the launched target app to emit a listening URL.
TimeSpan AppReadyTimeout { get; set; }
Gets or sets the maximum time to wait for the launched target app to respond as ready.
TimeSpan AppReadyPollInterval { get; set; }
Gets or sets the polling interval used while probing target app readiness.
A command for exporting a RazorWire site to a static directory.
ValueTask ExecuteAsync(IConsole console)
Executes the export process for the RazorWire site to the configured output directory, validating options and writing progress to the console.
consoleThe console used to write progress and completion messages.A ValueTask that completes when the export operation finishes.
ValueTask ExecuteAsync(IConsole console, CancellationToken cancellationToken)
Executes the export process using an explicit cancellation token.
consoleThe console used to write progress and completion messages.cancellationTokenCancellation token for startup and export operations.A ValueTask that completes when the export operation finishes.
string OutputPath { get; init; }
Gets or sets the path to the directory where the exported site will be written. Defaults to "dist".
string? SeedRoutesPath { get; init; }
Gets or sets an optional path to a file containing initial seed routes for the exporter.
string? BaseUrl { get; init; }
Gets or sets the base URL of a running application to crawl.
string? ProjectPath { get; init; }
Gets or sets a path to a .csproj file to run and export.
string? DllPath { get; init; }
Gets or sets a path to a .dll file to run and export.
string[] AppArgs { get; init; }
Gets or sets app arguments forwarded to the launched target app. Repeat this option for each token.
bool NoBuild { get; init; }
Gets or sets a value indicating whether project mode should skip build before launch.
A static generation engine that crawls a RazorWire application and exports its routes to static HTML files.
Task RunAsync(ExportContext context, CancellationToken cancellationToken = default)
Crawls the site starting from configured seed routes (or the root) and exports discovered pages and frame sources to the output path.
contextExport configuration and runtime state including base URL, output path, queue, and visited set.cancellationTokenToken to observe for cooperative cancellation of the crawl and export operations.A task that completes when the crawl and export operations have finished.
FileNotFoundExceptionThrown when ExportContext.SeedRoutesPath is specified but the file does not exist.If ExportContext.SeedRoutesPath is provided, the file is read and each line is validated and normalized to a root-relative route; invalid seeds are logged. If the seed file exists but yields no valid routes, the root path ("/") is enqueued. If no seed file is provided, the root path is enqueued. Discovered internal links and frame sources are queued and processed until the queue is exhausted or the operation is cancelled.
Task ExportRouteAsync(HttpClient client, string route, ExportContext context, CancellationToken cancellationToken)
Fetches the HTML or asset for the specified route from the base URL, writes the file to the output directory, and enqueues any discovered internal links for further export.
string MapRouteToFilePath(string route, string outputPath, bool isHtml)
Maps a root-relative route to an absolute file path inside the configured output directory.
void ExtractLinks(string html, ExportContext context)
Extracts root-relative internal link targets from the provided HTML and enqueues any unvisited routes for crawling.
htmlHTML source to scan.contextThe export context.void ExtractFrames(string html, ExportContext context)
Extracts root-relative `src` values from <turbo-frame> elements in the provided HTML and enqueues each unvisited path for export.
htmlHTML content to scan.contextThe export context.void ExtractAssets(string html, string currentRoute, ExportContext context)
Extracts root-relative asset references (scripts, styles, images) from the provided HTML and enqueues each unvisited path for export.
htmlHTML content to scan.currentRouteThe route of the page being scanned, used for resolving relative URLs.contextThe export context.string ResolveRelativeUrl(string baseRoute, string url)
Resolves a potentially relative URL against a base route.