Skip to content
Purview Dev logo

Aspire ResourceKit

Stable

Strongly typed, source-generated resource kits for .NET Aspire.

apphost aspire cloud-native code-generation csharp developer-tools distributed-systems dotnet dotnet-aspire integration-testing resource-management roslyn source-generators testing

The problem

A source-generator-powered framework for structuring .NET Aspire AppHost resource composition as strongly typed, test-friendly classes. Generated host wiring, typed options, and enablement toggles keep large AppHosts maintainable and discoverable.

From the repository

Source-generator-powered resource kits for .NET Aspire: turn AppHost resource composition into strongly typed, testable classes with generated host wiring, typed options, and enablement toggles for local, test, and publish modes.

Why it became a project

Large Aspire AppHosts repeatedly accumulated procedural resource wiring and configuration, creating a need for a typed, testable way to package those conventions.

Where it fits

Use it when

Your Aspire AppHost has reusable resource groups, configuration, or enablement rules that should be strongly typed, discoverable, and testable.

It may not fit when

Your AppHost is small and direct resource declarations remain clearer than introducing a resource-kit abstraction.

Use cases

Concrete examples of what Aspire ResourceKit does, and who each one is for.

Architect

Typed, testable resource groups in a large AppHost

A large Aspire AppHost accumulates procedural resource wiring and configuration that is hard to test and easy to misconfigure.

csharp
[HostKit]
partial class ShopHostKit;

[ResourceDefinition<Projects.Example_Service>("api")]
partial class ApiResourceKit
{
    protected override IResourceBuilder<ProjectResource> BuildResource(
        IDistributedApplicationBuilder builder)
        => builder.AddProject<Projects.Example_Service>(Name);
}

What you get: Resource definitions become strongly typed, source-generated classes with generated host wiring and typed options.

One [HostKit] plus one [ResourceDefinition] per resource replaces procedural AppHost code, and the analyzer validates the wiring at compile time.

Read the guide →
Team lead

Configure and toggle resources without editing the AppHost

You want enablement rules and configuration to be declarative and discoverable instead of buried in the AppHost entry point.

What you get: Typed options and enablement toggles are generated for each resource kit, so behaviour is configured rather than coded.

Resource kits can be unit tested with the testing helpers, independent of a running AppHost.

Read the guide →

Packages

1 package

Purview.Aspire.ResourceKitInstall ↓1.0.3—3,943

Install

.NET CLI
dotnet add package Purview.Aspire.ResourceKit