About this project
Purview.Aspire.ResourceKit is a source-generator-powered framework for structuring .NET Aspire AppHost resource composition as strongly typed, test-friendly classes.
## Purpose
When AppHost applications grow larger, keeping resource setup maintainable and discoverable becomes challenging. ResourceKit addresses this by moving composition logic into focused resource classes and generating the plumbing automatically.
## Key Benefits
- **Cleaner AppHost code**: Resource logic splits into dedicated classes rather than monolithic setup methods
- **Strong typing and IntelliSense**: Replaces stringly-typed configuration with compile-time safety
- **Generated wiring**: Automatically produces host/resource options and registration code
- **Predictable lifecycle**: Follows a Build then Configure pattern for managing inter-resource dependencies
- **Testability**: Supports options overrides and isolated resource composition for unit testing
## Usage Model
Define a host kit and resource classes using attributes:
```csharp
[HostKit]
partial class ShopHostKit;
[ResourceDefinition<ProjectResource>("api")]
partial class ApiResourceKit
{
protected override IResourceBuilder<ProjectResource> BuildResource(IDistributedApplicationBuilder builder)
=> builder.AddProject<Projects.Example_Service>(Name);
}
```
Then register in the AppHost:
```csharp
var builder = DistributedApplication.CreateBuilder(args);
builder.AddAspireResourceKit();
```
An extension method is generated from your host metadata (e.g., `AddAspireResourceKit()`).
## Lifecycle
ResourceKit implements a two-phase lifecycle:
1. **Build**: Construct individual resources (e.g., `AddProject`, `AddRedis`)
2. **Configure**: Attach resources together via references, bindings, and cross-resource wiring
Enablement controls when resources activate:
- `IsEnabled`: Persisted toggle typically sourced from generated options
- `IsResourceEnabled(builder)`: Runtime hook for evaluating environment, config, or publish mode
If a resource evaluates to disabled, both its Build and Configure phases are skipped entirely.
## Generated Artifacts
From `[HostKit]` and `[ResourceDefinition]` declarations, the source generator produces:
- A host resource base class
- Resource properties on the host
- Host-level and per-resource options (when enabled)
- An AppHost extension method for building, configuring, and registering the host kit
## Agent Skills
The package can bundle [Agent Skills](https://agentskills.io/) via `skills/**/SKILL.md` files. During build, these copy to `.agents/skills/` in the consuming project. Disable with:
```xml
<EnableAgentFolderInPackage>false</EnableAgentFolderInPackage>
```
## Repository Structure
- `src/src/ResourceKit`: Runtime package source
- `src/src/SourceGeneration`: Roslyn source generator
- `src/src/Example.*`: Sample Aspire applications
- `src/tests/*`: Unit and integration tests
## Documentation
- [Homepage](https://purview.dev/projects/aspire-resourcekit/)
- [Getting started](docs/wiki/Getting-Started.md)
- [Lifecycle-Build-Configure guide](docs/wiki/Lifecycle-Build-Configure.md)
- [Enablement documentation](docs/wiki/Enablement.md)
- [Configuration and options](docs/wiki/Configuration-and-Options.md)
- [Diagnostics and troubleshooting](docs/wiki/Diagnostics.md)
- [Examples: generated vs manual](docs/wiki/Examples.md)
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.