string Code { get; }
Source
Gets the short machine-readable diagnostic identifier.
Describes one CDN export validation problem with a stable code and actionable context.
Diagnostics are immutable value objects suitable for command-line output, logs, and structured inspection through ExportValidationException.Diagnostics. The public contract exposes the stable code, plain-text message, and route context. Internal exporter code may attach the discovered reference that produced the diagnostic for de-duplication and richer validation decisions.
string Code { get; }
Source
Gets the short machine-readable diagnostic identifier.
string Message { get; }
Source
Gets the human-readable plain-text validation message.
string Route { get; }
Source
Gets the root-relative route or export context where the diagnostic was produced.
ExportReference? Reference { get; }
Source
Gets the optional exporter-managed reference that produced the diagnostic.
This value is internal because it is tied to crawl provenance rather than the public validation exception contract. It is null for diagnostics that describe route-level failures instead of a specific markup or CSS reference.
Provides the RazorWire CLI entry surface with the command-first console behavior required for public tool flows.
Task RunAsync(string[] args, Action<ConsoleOptions>? configureOptions = null)
Source
Runs the RazorWire CLI directly through the command service while still allowing targeted startup customization.
argsCommand-line arguments supplied to the CLI.configureOptionsOptional console startup customization applied after RazorWire's defaults.A task that completes when the CLI command finishes running.
Public command-line tool entry points need predictable command output for help, validation errors, and export progress. Running the command service directly keeps those flows independent from the Generic Host lifecycle while preserving AppSurface's command registration, dependency injection, and unknown-option suggestions.
Represents exporter-domain validation failures that prevent CDN-safe output from being produced.
The export engine throws this exception without depending on CLI infrastructure. Command handlers should translate it into the appropriate command-line failure type for their host.
IReadOnlyList<ExportDiagnostic> Diagnostics { get; }
Source
Gets the diagnostics that describe why CDN export validation failed.
Structured command execution result used by the export resolver pipeline.
ExitCodeThe process exit code, or a synthetic negative value when process start failed before an operating-system exit code was available.StdoutThe captured standard output for the command.StderrThe captured standard error or a synthetic start-failure message.The resolver prefers this explicit result shape over exceptions for ordinary command failures so it can preserve stdout/stderr in logs and decide whether to throw, fall back to XML parsing, or continue probing.
Resolves export sources and, when needed, orchestrates launching a target application for crawling.
Task<ProcessResult> ExecuteProcessAsync(string fileName, IReadOnlyList<string> args, string workingDirectory, CancellationToken cancellationToken)
Source
Executes a command through the configured ICommandExecutor.
fileNameThe executable to start.argsThe ordered command-line arguments for the executable.workingDirectoryThe working directory used for process start.cancellationTokenCancels the command execution.A ProcessResult containing the exit code and captured output streams from the delegated executor.
This seam exists so resolver tests can verify command composition without launching real processes. Callers should treat a non-zero exit as data and decide whether to raise an exception or fall back.
Task<string> TryResolveAssemblyNameAsync(string projectPath, string fallbackName, string? framework, CancellationToken cancellationToken)
Source
Resolves the effective assembly name for a project, preferring MSBuild evaluation and falling back to raw project XML parsing when needed.
projectPathThe project file whose assembly name should be resolved.fallbackNameThe fallback assembly name when no explicit value can be determined.frameworkThe target framework used for MSBuild evaluation. Supplying this keeps conditional AssemblyName values aligned with the publish target.cancellationTokenCancels MSBuild evaluation.The assembly name reported by MSBuild when available; otherwise the value returned by TryResolveAssemblyNameFromXml.
OperationCanceledExceptionThrown when command execution is canceled.MSBuild is preferred because it evaluates imports and conditional properties that raw XML parsing cannot see. If MSBuild exits non-zero, produces no usable stdout, or throws a non-cancellation exception, the resolver logs the failure details and falls back to XML parsing. Omitting framework can mis-evaluate conditional AssemblyName declarations for multi-target projects.
string TryResolveAssemblyNameFromXml(string projectPath, string fallbackName)
Source
Reads a project file directly and returns the first explicit AssemblyName value found in the XML.
projectPathThe project file to inspect.fallbackNameThe value returned when the XML cannot be read or has no assembly name.The explicit AssemblyName from the project file, or fallbackName when no usable value is available.
This method intentionally does not evaluate imports or conditional MSBuild properties. It is the low-cost fallback used when MSBuild evaluation is unavailable or fails to return a usable value.
TimeSpan ListeningUrlTimeout { get; set; }
Source
Gets or sets the maximum time to wait for the launched target app to emit a listening URL.
TimeSpan AppReadyTimeout { get; set; }
Source
Gets or sets the maximum time to wait for the launched target app to respond as ready.
TimeSpan AppReadyPollInterval { get; set; }
Source
Gets or sets the polling interval used while probing target app readiness.
Creates validated export source requests from CLI options.
Selects how RazorWire export output should resolve internal application URLs.
The default selection is Cdn. Choose Cdn for output that will be served directly by a static host or CDN. Choose Hybrid only when the exported files will still be hosted behind infrastructure that preserves application routing and dynamic server behavior. New values must only be appended so existing serialized or logged enum values remain stable.
Identifies the HTML or CSS surface where an export reference was found.
Describes how to launch an external process.
string FileName { get; init; }
Source
Gets the executable file name.
IReadOnlyList<string> Arguments { get; init; }
Source
Gets the argument tokens passed to the process.
IReadOnlyDictionary<string, string> EnvironmentOverrides { get; init; }
Source
Gets environment variable overrides applied for process startup.
string WorkingDirectory { get; init; }
Source
Gets the working directory for the process.
A command for exporting a RazorWire site to a static directory.
ValueTask ExecuteAsync(IConsole console)
Source
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)
Source
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; }
Source
Gets or sets the path to the directory where the exported site will be written. Defaults to "dist".
string? SeedRoutesPath { get; init; }
Source
Gets or sets an optional path to a plain-text file containing one initial seed route per line.
This property is bound from the -r|--seeds command option. When it is null or empty, the exporter starts from the root route (/). When it points to a file, the exporter reads each line, accepts root-relative routes and absolute HTTP(S) URLs, strips query strings and fragments during normalization, and skips invalid, external, hash-only, JavaScript, or mailto entries. If the file is missing or unreadable, export fails and returns a non-zero CLI exit code. If the file is readable but contains no valid routes, the exporter logs a warning and falls back to the root route.
ExportMode Mode { get; init; }
Source
Gets or sets the export mode that controls whether output is rewritten for static CDN hosting.
ExportMode.Cdn is the default and emits fully static output for plain static hosts. Use ExportMode.Hybrid when the exported directory will still be served behind application-style routing that can resolve extensionless URLs.
string? BaseUrl { get; init; }
Source
Gets or sets the base URL of a running application to crawl.
string? ProjectPath { get; init; }
Source
Gets or sets a path to a .csproj file to run and export.
string? DllPath { get; init; }
Source
Gets or sets a path to a .dll file to run and export.
string? Framework { get; init; }
Source
Gets or sets an optional target framework for project exports, required for multi-target projects.
string[] AppArgs { get; init; }
Source
Gets or sets app arguments forwarded to the launched target app. Repeat this option for each token.
bool NoBuild { get; init; }
Source
Gets or sets a value indicating whether project mode should skip build before launch.
Provides context and state for an export operation, including configuration and crawl progress.
string OutputPath { get; }
Source
Gets the path where exported files will be saved.
string? SeedRoutesPath { get; }
Source
Gets the optional path to a seed routes file.
string BaseUrl { get; }
Source
Gets the base URL of the source application being exported.
ExportMode Mode { get; }
Source
Gets the export mode that controls URL rewriting and validation behavior.
ExportMode.Cdn is the default and rewrites exporter-managed internal URLs to emitted artifacts while validating that those managed dependencies can be served by a static host. ExportMode.Hybrid preserves application-style internal URLs for server-backed deployments that still provide routing and dynamic behavior. CDN validation and rewriting only apply to exporter-managed URLs discovered in markup and CSS; unmanaged external, JavaScript, mailto, hash-only, and data URLs are intentionally ignored rather than validated or rewritten.
HashSet<string> Visited { get; }
Source
Gets the set of URLs that have already been visited during the crawl.
Queue<string> Queue { get; }
Source
Gets the queue of URLs pending processing.
HashSet<string> Enqueued { get; }
Source
Gets the normalized routes that have already been scheduled for crawl processing.
This set mirrors Queue membership over the lifetime of an export so duplicate reference discovery can perform O(1) scheduling checks without scanning the pending queue. Routes remain in this set after dequeue because Visited and RouteOutcomes record their terminal crawl state.
Dictionary<string, ExportRouteOutcome> RouteOutcomes { get; }
Source
Gets route fetch outcomes keyed by normalized root-relative route.
List<ExportReference> References { get; }
Source
Gets every managed internal reference discovered during the crawl, including duplicate provenance.
List<ExportDiagnostic> Diagnostics { get; }
Source
Gets CDN validation diagnostics produced for this export.
Dictionary<string, string> ArtifactUrls { get; }
Source
Gets static-host artifact URLs keyed by normalized route.
Dictionary<string, string> PartialArtifactUrls { get; }
Source
Gets generated RazorDocs partial artifact URLs keyed by their source full-page route.
Represents a started or startable external target application process.
void Start()
Source
Starts the process and begins asynchronous output capture.
ValueTask DisposeAsync()
Source
Performs best-effort asynchronous cleanup of the started target process.
A task that completes after cleanup work finishes.
HasExited against the underlying process when startup completed.Kill(entireProcessTree: true) and then wait up to 5 seconds for exit, even when kill throws a recoverable cleanup exception.WaitForExit() to flush redirected stdout and stderr callbacks before returning.InvalidOperationException, timeout-driven OperationCanceledException, ObjectDisposedException, and recoverable kill, wait, or flush exceptions such as Win32Exception or NotSupportedException as part of best-effort disposal.bool HasExited { get; }
Source
Gets a value indicating whether the process has exited.
Creates ITargetAppProcess instances for launch specifications.
ITargetAppProcess Create(ProcessLaunchSpec spec)
Source
Creates a new process wrapper for the provided launch spec.
specThe process launch specification.A process wrapper ready to start.
Default ITargetAppProcessFactory implementation.
Optional process-operation overrides for TargetAppProcess tests.
These hooks exist so tests can force cleanup branches such as unsupported kill operations, synthetic exit states, or timeout handling without reflection or fragile platform-dependent child processes.
Action<TargetAppProcess>? StartOverride { get; init; }
Source
Gets or sets an optional start override used in place of Process.Start() and output-reader setup.
Tests can use this to deterministically raise ITargetAppProcess.Exited and ITargetAppProcess.OutputLineReceived in a controlled order without depending on operating-system process timing.
Func<Process, bool>? HasExitedOverride { get; init; }
Source
Gets or sets an optional exit-state override used in place of Process.HasExited.
Action<Process>? KillProcessOverride { get; init; }
Source
Gets or sets an optional kill override used in place of Process.Kill(bool).
Func<Process, CancellationToken, Task>? WaitForExitAsyncOverride { get; init; }
Source
Gets or sets an optional asynchronous wait override used in place of Process.WaitForExitAsync(CancellationToken).
Action<Process>? WaitForExitOverride { get; init; }
Source
Gets or sets an optional synchronous wait override used in place of Process.WaitForExit().
A static generation engine that crawls a RazorWire application and exports its routes to CDN or hybrid static files.
Task RunAsync(ExportContext context, CancellationToken cancellationToken = default)
Source
Crawls the site starting from configured seed routes (or the root), stages the conventional reserved 404 page when available, validates CDN output when requested, and exports discovered pages, frame sources, and assets 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.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. Before crawl processing begins, the engine probes AppSurface's reserved conventional 404 route and stages 404.html when the route returns a successful HTML response. That reserved-route probe is best-effort only: failures are logged, do not abort the crawl, and do not prevent queued seed routes from being processed. Once staged, the 404.html body participates in the same CDN validation and reference rewriting as other HTML artifacts. Export then runs as a three-stage pipeline: seed queue -> crawl/fetch/discover -> CDN validation -> materialize/rewrite The crawl stage records route outcomes, artifact URLs, and reference provenance. In CDN mode, HTML and CSS bodies are kept once until materialization so managed URLs can be rewritten after the artifact map is complete. In hybrid mode, text artifacts and binary assets are written directly to their final files and only their outcomes are retained in memory.Task CrawlRouteAsync(HttpClient client, string route, ExportContext context, CancellationToken cancellationToken)
Source
Fetches the HTML or asset for the specified route, records export graph metadata, and enqueues discovered managed references.
bool IsDocsExportPage(string route, string html, string? docContentFrame = null)
Source
Determines whether an exported HTML page should receive RazorDocs static partial support.
routeThe root-relative route being exported.htmlThe fetched HTML document.docContentFrameThe extracted doc-content frame, when the caller has already parsed it.true for the legacy /docs route family or HTML that carries RazorDocs runtime markers; otherwise false.
Custom RazorDocs hosts can mount under route families such as /foo/bar, so export detection cannot rely only on path prefixes. The client config marker covers search and shell pages, while the content frame covers document detail pages.
string MapRouteToFilePath(string route, string outputPath, bool isHtml)
Source
Maps a root-relative route to an absolute file path inside the configured output directory.
void ExtractLinks(string html, ExportContext context, string currentRoute = "/")
Source
Extracts root-relative internal link targets from the provided HTML and enqueues any unvisited routes for crawling.
htmlHTML source to scan.contextThe export context.currentRouteThe route used to resolve relative anchor URLs and record source provenance.void ExtractFrames(string html, ExportContext context, string currentRoute = "/")
Source
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.currentRouteThe route used to resolve relative frame source URLs and record source provenance.void ExtractAssets(string html, string currentRoute, ExportContext context)
Source
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.IReadOnlyList<ExportReference> ExtractReferences(string content, string currentRoute, bool htmlScope)
Source
Extracts exporter-managed internal references from HTML or CSS content.
contentThe HTML document, style block, style attribute, or stylesheet body to scan.currentRouteThe normalized route that owns content, used to resolve relative URLs and record provenance.htmlScopetrue scans HTML surfaces including anchors, Turbo Frames, scripts, supported link tags, image sources, srcset candidates, style blocks, and style attributes. Anchors marked with data-rw-export-ignore, and relative anchors pointing at common source or project file extensions, are skipped so authoring-only source-navigation links can remain clickable without becoming CDN dependencies. false scans only CSS url(...) references.References with managed root-relative paths only. External URLs, protocol-relative URLs, hash-only references, data URLs, JavaScript URLs, mailto links, and malformed values are filtered out before the caller enqueues or validates them.
string ResolveRelativeUrl(string baseRoute, string url)
Source
Resolves a potentially relative URL against a base route.
Provides a testable wrapper around the RazorWire CLI top-level entrypoint.
Task RunAsync(string[] args, Action<ConsoleOptions>? configureOptions = null)
Source
Runs the RazorWire CLI using the same command-first startup path as the shipped program entrypoint.
argsCommand-line arguments supplied to the CLI.configureOptionsOptional console startup customization applied before the CLI host starts.A task that completes when CLI execution finishes.
IDisposable PushConfigureOptionsOverrideForTests(Action<ConsoleOptions> configureOptions)
Source
Temporarily injects additional console startup configuration for the duration of a test that invokes the real assembly entrypoint.
configureOptionsTest-only console startup customization applied after any explicit caller configuration.A disposable scope that restores the previous override when disposed.
Records the fetch and materialization state for one normalized export route.
ExportRouteOutcome Success(string route, string? contentType, string artifactPath, string artifactUrl, string? textBody)
Source
Creates a successful route outcome with emitted artifact details.
routeNormalized root-relative route that was crawled, such as / or /docs/start.contentTypeResponse media type when known, or null when the server omitted it.artifactPathAbsolute output file path written for the route.artifactUrlStatic-host URL that resolves to the emitted artifact.textBodyCaptured HTML or CSS body retained for later validation and rewriting, or null for streamed assets.An outcome with Succeeded set to true, artifact fields populated, and no status code or exception.
ExportRouteOutcome Success(string route, string? contentType, string artifactPath, string artifactUrl)
Source
Creates a successful route outcome for an artifact whose body does not need deferred validation or rewriting.
routeNormalized root-relative route that was crawled, such as / or /docs/start.contentTypeResponse media type when known, or null when the server omitted it.artifactPathAbsolute output file path written for the route.artifactUrlStatic-host URL that resolves to the emitted artifact.An outcome with Succeeded set to true, artifact fields populated, and no retained body.
ExportRouteOutcome NonSuccess(string route, HttpStatusCode statusCode)
Source
Creates an outcome for a route that completed at the HTTP layer with a non-success status code.
routeNormalized root-relative route that was crawled.statusCodeHTTP status code returned by the source application.An outcome with Succeeded set to false, StatusCode populated, and no artifact or exception fields.
ArgumentExceptionThrown when route is null, empty, or whitespace.ArgumentOutOfRangeExceptionThrown when statusCode is a successful 2xx HTTP status code.ExportRouteOutcome Failed(string route, Exception exception)
Source
Creates an outcome for a route that failed because an exception interrupted fetch or write processing.
routeNormalized root-relative route that was being processed.exceptionException that prevented the route from completing.An outcome with Succeeded set to false, Exception populated, and no status or artifact fields.
string Route { get; }
Source
Gets the normalized root-relative route that was fetched.
bool Succeeded { get; }
Source
Gets a value indicating whether the route fetched successfully.
string? ContentType { get; }
Source
Gets the response media type when one was available, optionally including media-type parameters.
HttpStatusCode? StatusCode { get; }
Source
Gets the non-success response status code when the fetch failed at the HTTP layer.
string? ArtifactPath { get; }
Source
Gets the absolute output file path for a successful route.
string? ArtifactUrl { get; }
Source
Gets the static-host URL that should be used to reach the emitted artifact.
string? TextBody { get; }
Source
Gets the fetched HTML or CSS body retained until materialization.
Exception? Exception { get; }
Source
Gets the exception that prevented the route from being fetched or written.
bool IsHtml { get; }
Source
Gets a value indicating whether the route was fetched as HTML.
bool IsCss { get; }
Source
Gets a value indicating whether the route was fetched as CSS.
A terminal/CLI module for RazorWire providing static site export capabilities.
void ConfigureServices(StartupContext context, IServiceCollection services)
Source
Configures services needed for the CLI, including the export pipeline and command-owned logging defaults.
contextThe startup context.servicesThe service collection to populate.void ConfigureHostBeforeServices(StartupContext context, IHostBuilder builder)
Source
Executes pre-service host configuration; currently no implementation is required.
contextThe startup context.builderThe host builder.void ConfigureHostAfterServices(StartupContext context, IHostBuilder builder)
Source
Executes post-service host configuration; currently no implementation is required.
contextThe startup context.builderThe host builder.void RegisterDependentModules(ModuleDependencyBuilder builder)
Source
Registers dependencies for this module; currently no implementation is required.
builderThe module dependency builder.Describes one exporter-managed internal URL discovered while crawling HTML or CSS.
RawValue is the exact value found in markup or CSS. ResolvedUrl is the root-relative URL after resolving relative references against SourceRoute. Path is the query-free route used for fetch de-duplication, while Query and Fragment preserve the original URL shape for CDN validation and rewriting decisions.
bool IsAsset { get; }
Source
Gets a value indicating whether the reference points at an asset-like dependency rather than a page route.
Default ICommandExecutor implementation backed by Process.
This implementation models launch failures as ProcessResult instances instead of throwing so resolver code can treat command execution as data and decide whether to fall back or raise a richer exception. If the command is canceled after launch starts, cancellation is propagated and the finally block still attempts to stop the child process tree.
Task<ProcessResult> ExecuteCommandAsync(string fileName, IReadOnlyList<string> args, string workingDirectory, CancellationToken cancellationToken)
Source
Starts a child process, captures its output streams, and returns the resulting ProcessResult.
fileNameThe executable to launch.argsThe ordered command-line arguments passed to the executable.workingDirectoryThe working directory supplied to the process start info.cancellationTokenCancels the process wait and output reads.A ProcessResult whose fields contain the exit code, stdout, and stderr on success, or a synthetic failure result when the process cannot be started.
OperationCanceledExceptionThrown when cancellation is observed after launch begins.The method intentionally returns ProcessResult for launch/setup failures so callers can preserve command context in their own diagnostics. The finally block always attempts Kill(entireProcessTree: true) for started processes, so callers should assume cancellation or mid-flight failures may terminate child processes spawned by the launched command.
Executes child processes for the export pipeline while preserving a structured ProcessResult contract for callers.
This abstraction exists so resolver logic can verify command composition without launching real processes in tests. Callers should prefer it whenever they need stdout, stderr, exit code, and cancellation behavior surfaced in a consistent shape.
Task<ProcessResult> ExecuteCommandAsync(string fileName, IReadOnlyList<string> args, string workingDirectory, CancellationToken cancellationToken)
Source
Executes a command and captures its exit code, standard output, and standard error.
fileNameThe executable to start.argsThe ordered command-line arguments passed to fileName.workingDirectoryThe working directory used for process start.cancellationTokenCancels the launched process and any in-flight output reads.A ProcessResult whose ExitCode, Stdout, and Stderr describe the completed command or a start-up failure.
Implementations should avoid throwing for ordinary process start failures so higher-level callers can decide whether to surface an exception, retry, or fall back. Cancellation should still propagate via OperationCanceledException.