Agent Skills
› managedcode/dotnet-skills
› aspire
aspire
GitHub指导使用 Aspire CLI 和 AppHost SDK 构建、升级及运行分布式应用,涵盖服务编排、集成配置、测试验证与部署。
Trigger Scenarios
使用 Aspire.AppHost.Sdk 或 DistributedApplication.CreateBuilder 创建应用主机
配置 ServiceDefaults、OpenTelemetry 或健康检查
将多个微服务整合到 Aspire 拓扑中进行本地开发或云部署
升级旧版 Aspire 解决方案至当前版本
Install
npx skills add managedcode/dotnet-skills --skill aspire -g -y
SKILL.md
Frontmatter
{
"name": "aspire",
"description": "Build, upgrade, and operate Aspire 13.4.x C# or TypeScript application hosts with the current CLI, AppHost, ServiceDefaults, integrations, dashboard, testing, MCP, and deployment patterns for distributed apps. USE FOR: Aspire.AppHost.Sdk, Aspire.Hosting.*, DistributedApplication.CreateBuilder, apphost.mts, createBuilder, WithReference, WaitFor, AddProject, AddRedis, AddPostgres, aspire run, aspire init, aspire. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.",
"compatibility": "Best for current Aspire 13.4.x tooling with .NET 10 or a supported Node.js runtime for TypeScript AppHosts; use version-aware upgrade guidance for older 8.x or 9.x solutions."
}
Aspire
Trigger On
Aspire.AppHost.Sdk,Aspire.Hosting.*,DistributedApplication.CreateBuilder,apphost.mts,createBuilder,WithReference,WaitFor,AddProject,addNodeApp,addViteApp,AddRedis,AddPostgres,aspire run,aspire init,aspire add, oraspire updateAspire.Hosting.Testing,DistributedApplicationTestingBuilder, or a test harness that mixes an Aspire AppHost withWebApplicationFactory- orchestrating multiple services and resources with an AppHost for local development or cloud deployment
- setting up
ServiceDefaults, service discovery, OpenTelemetry, health checks, or the Aspire Dashboard - choosing between official first-party Aspire integrations and
CommunityToolkit/Aspire - upgrading older 8.x or 9.x Aspire solutions to the current CLI and AppHost SDK model
- wiring polyglot services into an Aspire topology, especially when Go, Bun, Java, Python, or extra dev-time tools enter the picture
Workflow
- Classify the task first: new AppHost creation, existing-solution enlistment, integration wiring, testing and observability, deployment, or version upgrade.
- Prefer the current Aspire toolchain. Choose a C# AppHost for .NET-first repositories or a TypeScript
apphost.mtsfor JavaScript/TypeScript-first repositories; both are first-class in 13.4. Use the Aspire CLI and current SDK-generated app model instead of writing new guidance around the deprecated legacy workload. - Treat 13.4.x releases as servicing and feature updates for the current CLI-first app model, not a topology rewrite. Keep the Aspire CLI,
Aspire.AppHost.Sdk, and closely coupled hosting or testing packages on the same line, then rerun the AppHost and deployment checks afteraspire update. - Keep the AppHost code-first and topology-focused. Model services, resources, dependencies, endpoints, lifetimes, and parameters there; keep business logic out.
- Keep
ServiceDefaultsnarrow. It exists for telemetry, health checks, resilience, and service discovery, not shared domain models or general utility code. - Prefer official first-party Aspire integrations when they cover the requirement. Use
CommunityToolkit/Aspireonly when the capability gap is real: unsupported language hosts, extra dev infrastructure, or extension packages the official project does not provide. - Validate the whole distributed system, not one project in isolation. Local success means the AppHost starts cleanly, dependencies resolve through
WithReference, the dashboard shows the expected resource graph, and end-to-end tests can exercise the topology. - For integration tests, keep one shared AppHost fixture per test session. Use
Aspire.Hosting.Testingto boot the distributed app, createHttpClientor SignalR clients from the AppHost, and layerWebApplicationFactoryon top only when tests need direct Host DI, grains, or runtime services. - When publishing, switch from local containers or emulators to managed resources deliberately and verify which services truly need external endpoints.
Architecture
flowchart LR
A["Distributed-app task"] --> B{"Need code-first orchestration?"}
B -->|No| C["Stay in service-level skills such as ASP.NET Core, Worker, or Orleans"]
B -->|Yes| D["Create or update the AppHost"]
D --> E["Model resources and services with `WithReference` and `WaitFor`"]
E --> F{"Official Aspire integration exists?"}
F -->|Yes| G["Use first-party Aspire integration"]
F -->|No or gap remains| H["Evaluate `CommunityToolkit/Aspire`"]
G --> I["Apply `ServiceDefaults`, dashboard, and tests"]
H --> I
I --> J{"Publishing now?"}
J -->|No| K["Run locally with `aspire run` or the AppHost project"]
J -->|Yes| L["Choose `azd`, App Service, or the CLI deploy/publish pipeline"]
Current Guidance
- AppHost shape: recognize three current first-class forms: an SDK-style C# AppHost project using
Aspire.AppHost.Sdk/<version>, a file-based C#apphost.cs, or a TypeScriptapphost.mts. For TypeScript,aspire init --language typescriptwritesaspire.config.jsonand the generated.aspire/modules/SDK; do not hand-edit generated modules, and runaspire restoreafter package/integration changes. - TypeScript AppHosts: use the async lower-camel-case app model (
createBuilder,addNodeApp,addViteApp,withReference,waitFor,build().run()). In an existing repository with a rootpackage.json, expect the CLI to create a nestedaspire-apphost/package so the application and orchestration toolchains stay separate. - Polyglot hosting: Aspire 13.4 adds first-party Go and Bun support, and 13.5 makes TypeScript AppHosts generally available. Prefer the official hosting surface for new Go, Bun, or TypeScript resources before considering older toolkit integrations; keep community integrations for languages and capabilities that still have a real first-party gap.
- CLI entry points: use
aspire newfor starter projects,aspire initto add Aspire support to an existing solution or create a single-file AppHost,aspire addto add integrations or starter pieces,aspire runfor local orchestration,aspire start/aspire stop/aspire psfor detached lifecycle management,aspire describefor live resource inspection,aspire doctorfor environment diagnostics,aspire secretfor user secrets,aspire docsfor terminal documentation lookup,aspire agentfor AI agent integration,aspire deployfor the current CLI deploy pipeline,aspire restorefor AppHost and TypeScript resource refresh, andaspire updatefor version-aware upgrades.aspire terminalattaches to an opt-inWithTerminal()resource; do not make an interactive terminal a hidden dependency of normal orchestration.aspire publishstill exists for explicit artifact-generation flows and remains preview-sensitive. - Upgrade posture: Aspire
13.5.0adds cross-language interaction controls, experimentalWithTerminal()resources, a refreshed dashboard, and more deployment modeling. Before upgrading, audit its breaking changes: hosting-contextServiceProviderbecameServices,PublishAsConnectionStringis superseded byAddConnectionString, and the removedaspire ps --resources/--include-hiddenviews becomeaspire describe. Align package versions, runaspire update --migratewhen it applies, then revalidate local orchestration and the chosen deployment path. - MCP and agent tooling:
ExcludeFromMcp()filtering is now consistently honored by CLI MCP tools such as resource, log, command, and trace listings. Use it deliberately for resources that should not leak into agent context. - DCP reliability: current 13.4 servicing retries dropped DCP requests and lets isolated AppHosts bind distinct resource-service ports. If AppHost resource commands or dashboard-backed CLI calls were flaky, upgrade before adding local retry wrappers.
- App model wiring: use
WithReference(...)for dependency and configuration flow, andWaitFor(...)for startup ordering. UseWithExternalHttpEndpoints()only when the resource truly needs an externally reachable endpoint for the chosen runtime or publish target. - ServiceDefaults boundaries:
AddServiceDefaults()should stay focused on OpenTelemetry, health endpoints, service discovery,HttpClientresilience, and related cross-cutting infrastructure. - Testing model: prefer Aspire closed-box testing when you need to run the distributed application as a system. Use
DistributedApplicationTestingBuilderplus a shared fixture for AppHost lifecycle,App.CreateHttpClient(...)for resource-bound clients, and aWebApplicationFactory<TEntryPoint>wrapper only when the test must resolve DI services or in-process runtime state from the hosted app. For UI flows, initialize Playwright once in the shared fixture, create a fresh browser context per test, and capture failure artifacts. - Dashboard usage: treat the Aspire Dashboard as the development observability surface. It is valuable in AppHost runs and standalone OTLP scenarios, but it is not a production monitoring replacement.
- Upgrade posture: older 8.x or 9.x solutions need explicit migration work. Current guidance favors the Aspire CLI upgrade path and the newer AppHost SDK structure on
.NET 10.
Selection Rules
- Use first-party Aspire when the package and docs exist for the resource or platform, especially for core .NET, Azure, cache, database, messaging, Microsoft Foundry, and standard local-container flows.
- Treat C# and TypeScript as AppHost-language choices, not different orchestration products. Keep topology semantics aligned while using the API casing, generated SDK, validation, and package-manager workflow native to the chosen host language.
- Use
CommunityToolkit/Aspirewhen you need polyglot app hosts beyond official coverage, extra dev-time tools around a resource, or community-maintained integrations such as SQLite, Java, PowerShell, Deno, Rust, k6, MailPit, MinIO, or Meilisearch. - Prefer the smallest surface that solves the problem. Do not add a broad toolkit extension pack when an existing first-party integration plus a normal library already fits.
- Treat toolkit packages as community-supported. Verify maturity, maintenance, external container images, and security or licensing assumptions before making them part of a production baseline.
Official Sources
- Aspire docs home
- What's new in Aspire 13.5
- AppHost
- Service defaults
- Integrations overview
- Build your first app
- Aspire CLI reference
- TypeScript AppHost project structure
- Aspire 13.5.0 release
- Testing overview
- microsoft/aspire
- CommunityToolkit/Aspire
Anti-Patterns
- hardcoding service URLs or connection strings instead of using
WithReference - putting business logic, data migrations, or large configuration transforms inside the AppHost
- turning
ServiceDefaultsinto a dumping ground for shared models or helpers - adding external HTTP endpoints everywhere instead of only where runtime or publish needs them
- defaulting to
CommunityToolkit/Aspirewhen first-party Aspire already covers the requirement - assuming the dashboard or local containers automatically mean production readiness
- treating Aspire tests as a mocking framework; they run the application as a real distributed system
Deliver
- a version-aware Aspire architecture or upgrade direction
- the right AppHost, ServiceDefaults, integration, and CLI workflow
- an explicit first-party versus
CommunityToolkit/Aspirepackage decision - an end-to-end validation path for local orchestration, testing, and deployment
Validate
- the AppHost starts cleanly via
aspire runor the AppHost project - resources and projects are modeled with explicit
WithReferenceandWaitForrelationships where needed - consuming apps resolve endpoints and connection strings without hardcoded values
ServiceDefaultscontains only cross-cutting infrastructure concerns- dashboard, health checks, logs, and traces reflect the expected resource graph
- Aspire-backed integration tests reuse a shared AppHost fixture instead of booting the distributed app inside each test
- any
WebApplicationFactorylayer reuses connection strings and endpoints from the AppHost instead of duplicating local config - testing and deployment guidance matches the chosen runtime: local AppHost, standalone dashboard, ACA/App Service, or the CLI deploy/publish pipeline
References
- patterns.md - Current CLI-first setup flows, AppHost patterns,
ServiceDefaults, testing, and upgrade checkpoints - testing.md - Shared AppHost fixtures,
DistributedApplicationTestingBuilder,WebApplicationFactoryintegration, Playwright bootstrapping, and diagnostics - deployment.md - ACA, App Service, publish-mode, and manifest-oriented deployment guidance
- community-toolkit.md - Practical guide to
CommunityToolkit/Aspirepackages, capability gaps, and selection rules
Version History
- 0559476 Current 2026-08-19 23:30
- 7ab7f03 2026-07-25 05:21


