RazorDocs Search
API Reference

Tailwind

Type

TailwindExtensions

Source

Provides extension methods for registering Tailwind CSS services.

Method

AddTailwind

2 overloads
IServiceCollection AddTailwind(this IServiceCollection services) Source

Adds Tailwind CSS services to the service collection.

Parameters

  • servicesThe service collection.

Returns

The service collection for chaining.

Remarks

Use this overload when the default TailwindOptions are sufficient. It delegates to AddTailwind(IServiceCollection, Action{TailwindOptions}) and registers both TailwindCliManager and the hosted TailwindWatchService. In tests or non-hosted scenarios, remember that the hosted watch service can start background file/process work.

IServiceCollection AddTailwind(this IServiceCollection services, Action<TailwindOptions> configureOptions) Source

Adds Tailwind CSS services with custom configuration to the service collection.

Parameters

  • servicesThe service collection.
  • configureOptionsAn action to configure the TailwindOptions.

Returns

The service collection for chaining.

Remarks

Use this overload to customize TailwindOptions before AppSurface registers TailwindCliManager and TailwindWatchService. The watch service is registered as an IHostedService, so hosts that should not run Tailwind background work should avoid this extension or replace the hosted service registration intentionally.

Type

TailwindCliManager

Source

Manages the location and execution of the Tailwind CLI binary.

Method

GetTailwindPath

string GetTailwindPath() Source

Gets the path to the Tailwind CLI binary.

Returns

The absolute path to the tailwindcss executable.

Exceptions

  • FileNotFoundExceptionThrown if the binary cannot be found in runtimes, local directory, or PATH.

Remarks

Resolution proceeds in this order:
  1. RID-specific runtime assets under AppContext.BaseDirectory.
  2. A flat binary next to the application under AppContext.BaseDirectory.
  3. RID-specific runtime assets relative to this assembly, including local development runtime build outputs when running inside this repository.
  4. The system PATH as an escape hatch for custom or Node-managed Tailwind setups, including Windows shell shims such as .cmd and .ps1.
If none of these locations contain a compatible binary, the method throws FileNotFoundException.
Method

BuildInvocation

TailwindCliInvocation BuildInvocation(string tailwindPath, IReadOnlyList<string> tailwindArgs) Source

Builds the process invocation needed to execute a resolved Tailwind CLI path.

Parameters

  • tailwindPathThe resolved Tailwind CLI path returned by GetTailwindPath.
  • tailwindArgsThe Tailwind CLI arguments to forward to the process.

Returns

A TailwindCliInvocation describing the executable to launch and the full ordered argument list.

Remarks

Windows PATH resolution can return Node-managed shell shims such as .cmd or .ps1. These files cannot be launched reliably with System.Diagnostics.ProcessStartInfo.UseShellExecute disabled, so they are wrapped with cmd.exe or powershell.exe as appropriate.

Method

GetCurrentRid

string GetCurrentRid() Source

Gets the Runtime Identifier (RID) for the current platform.

Returns

The RID string (e.g., "win-x64", "linux-arm64").

Remarks

Must be kept in sync with the RID logic in the runtime package projects and build/ForgeTrust.AppSurface.Web.Tailwind.targets. Unsupported operating systems or architectures return "unknown". Windows Arm64 intentionally maps to win-x64 because Tailwind v4.1.18 does not ship a native Windows Arm64 standalone binary.

Method

ResolveRid

string ResolveRid(OSPlatform osPlatform, Architecture architecture) Source

Resolves the Tailwind runtime identifier for a specific platform and process architecture.

Parameters

  • osPlatformThe operating system platform to evaluate.
  • architectureThe process architecture to map.

Returns

The Tailwind runtime identifier for the supplied platform/architecture pair.

Remarks

Must be kept in sync with the RID logic in the runtime package projects and build/ForgeTrust.AppSurface.Web.Tailwind.targets.

Property

BaseDirectoryOverride

string? BaseDirectoryOverride { get; set; } Source

Gets or sets a directory to override AppContext.BaseDirectory for testing.

Property

AssemblyDirectoryOverride

string? AssemblyDirectoryOverride { get; set; } Source

Gets or sets a directory to override the resolved assembly directory for testing isolated fallback lookup.

Property

RidOverride

string? RidOverride { get; set; } Source

Gets or sets a runtime identifier override for tests that need to exercise non-host RID resolution paths.

Property

IsOSPlatformOverride

Func<OSPlatform, bool>? IsOSPlatformOverride { get; set; } Source

Gets or sets an operating-system detector override for tests that need deterministic platform simulation.

Property

ProcessArchitectureOverride

Func<Architecture>? ProcessArchitectureOverride { get; set; } Source

Gets or sets a process-architecture override for tests that need deterministic RID resolution.

Type

TailwindCliInvocation

Source

Represents the concrete process invocation required to launch the resolved Tailwind CLI.

Parameters

  • FileNameThe executable or launcher to start.
  • ArgumentsThe complete ordered argument list to pass to FileName.
Type

TailwindWatchService

Source

A background service that runs the Tailwind CLI in watch mode during development.

Method

ExecuteTailwindProcessAsync

Task<CommandResult> ExecuteTailwindProcessAsync(string fileName, IReadOnlyList<string> args, string workingDirectory, CancellationToken cancellationToken) Source

Executes the Tailwind CLI process.

Parameters

  • fileNameThe path to the executable.
  • argsThe arguments.
  • workingDirectoryThe working directory.
  • cancellationTokenThe cancellation token.

Returns

The command result returned by the Tailwind CLI process.

Remarks

Internal virtual to allow mocking in unit tests.

Method

GetPathComparison

StringComparison GetPathComparison() Source

Resolves the path-comparison behavior used when validating Tailwind input/output paths.

Returns

The string-comparison behavior used when evaluating Tailwind input and output paths.

Remarks

The default implementation only assumes case-insensitive paths on Windows so development hosts on case-sensitive volumes are not rejected by a false positive same-file check. Override HostPathsAreCaseInsensitive in tests or specialized hosts that know they should compare paths case-insensitively on another platform.

Method

HostPathsAreCaseInsensitive

bool HostPathsAreCaseInsensitive() Source

Determines whether the current host should treat filesystem paths as case-insensitive for Tailwind path validation.

Returns

true when the host should conservatively compare input and output paths case-insensitively; otherwise false.

Remarks

The default behavior treats only Windows as case-insensitive. Hosts that run on a known case-insensitive non-Windows volume can override this method to opt into StringComparison.OrdinalIgnoreCase.

Type

TailwindOptions

Source

Configuration options for the Tailwind CSS integration.

Remarks

Use these options with services.AddTailwind(...) to control both build-time compilation and development watch behavior. Defaults:
  • Enabled defaults to true.
  • InputPath defaults to wwwroot/css/app.css.
  • OutputPath defaults to wwwroot/css/site.gen.css.
Paths are resolved relative to the app content root. Common misconfigurations include pointing at a missing input file, using whitespace-only paths, or choosing an output path whose parent directory is not writable.
Property

Enabled

bool Enabled { get; set; } Source

Gets or sets a value indicating whether Tailwind CSS integration is enabled.

Remarks

Leave this enabled for normal development and build pipelines. Set it to false only when a host intentionally opts out of Tailwind compilation or provides CSS through another mechanism.

Property

InputPath

string InputPath { get; set; } Source

Gets or sets the path to the input CSS file.

Remarks

Defaults to wwwroot/css/app.css. The value should be a non-empty relative path to a readable .css file under the application content root.

Property

OutputPath

string OutputPath { get; set; } Source

Gets or sets the path to the output CSS file.

Remarks

Defaults to wwwroot/css/site.gen.css. The value should be a non-empty relative path whose parent directory exists and is writable. Keep the output under wwwroot/ when the generated stylesheet needs to participate in ASP.NET Core static web asset discovery for build and publish output. Avoid pointing this at the same file as InputPath.