aspire-orchestration

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Aspire Orchestration

Aspire 编排

MANDATORY COMPLIANCE — This skill prevents agent self-harm in Aspire projects. Violating these rules causes file locks, orphaned processes, and user frustration (#15801).
强制合规要求 —— 本技能可避免Aspire项目中的代理自损问题。 违反这些规则会导致文件锁、孤立进程和用户困扰(#15801)。

Prerequisites

前置条件

RequirementInstall
.NET 10.0 SDKhttps://dotnet.microsoft.com/download
Aspire CLI (curl/PowerShell)
curl -sSL https://aspire.dev/install.sh | bash
Aspire CLI (NativeAOT global tool, .NET 10)
dotnet tool install -g Aspire.Cli
Either install method works. The
dotnet tool install
path produces a NativeAOT binary (instant startup, no JIT warmup) and is the recommended option when .NET 10 is already present.
要求安装方式
.NET 10.0 SDKhttps://dotnet.microsoft.com/download
Aspire CLI(curl/PowerShell)
curl -sSL https://aspire.dev/install.sh | bash
Aspire CLI(NativeAOT全局工具,.NET 10)
dotnet tool install -g Aspire.Cli
两种安装方式均可。若已安装.NET 10,推荐使用
dotnet tool install
方式,该方式会生成NativeAOT二进制文件(启动速度快,无需JIT预热)。

Detection

检测机制

Activate when ANY signal is present:
SignalHow to DetectConfidence
C# AppHost
.csproj
containing
Aspire.AppHost.Sdk
✅ Definitive
File-based C# AppHost
apphost.cs
or
.cs
file with
#:sdk Aspire.AppHost.Sdk
✅ Definitive
TypeScript AppHost
apphost.ts
file in project
✅ Definitive
Aspire config
aspire.config.json
in project root
High
Aspire settings
.aspire/
directory present
High
Generated TS modules
.aspire/modules/
directory present
High
Service defaults
Aspire.ServiceDefaults
in project references
Medium
See detection.md for detailed fingerprinting.
当出现以下任一信号时激活本技能:
信号检测方式置信度
C# AppHost包含
Aspire.AppHost.Sdk
.csproj
文件
✅ 确定
基于文件的C# AppHost包含
#:sdk Aspire.AppHost.Sdk
apphost.cs
.cs
文件
✅ 确定
TypeScript AppHost项目中的
apphost.ts
文件
✅ 确定
Aspire配置项目根目录下的
aspire.config.json
文件
Aspire设置存在
.aspire/
目录
生成的TS模块存在
.aspire/modules/
目录
服务默认项项目引用中包含
Aspire.ServiceDefaults
详细指纹识别规则请查看detection.md

Safety Guardrails

安全防护规则

Situation✅ ALWAYS Do❌ NEVER Do
Start an Aspire app
aspire start
dotnet run
on AppHost
Wait for resource ready
aspire wait <resource>
curl
/ HTTP polling loops
Code changed in a resourcePrefer resource commands, runtime watch/HMR, dashboard actions, or IDE-managed debugging
dotnet build
against locked files
Task complete
aspire stop
Leave processes running
Check resource status
aspire describe
/
aspire ps
Manual process inspection
Working in git worktree
aspire start --isolated
aspire start
without isolation
Running from AI agentAdd
--non-interactive
to all commands
Assuming interactive terminal
Editing unfamiliar API
aspire docs search <topic>
then
aspire docs api search <query>
for API reference
Guessing API shape
C# AppHost API inspectionUse
dotnet-inspect
skill (if available) for local symbols
Guessing overloads or builder chains
Adding custom dashboard/resource commands
aspire docs search "custom resource commands"
first
Inventing
WithCommand
patterns without docs
Installing Aspire supportUse
aspire add
or
aspire init
dotnet workload install aspire
(obsolete)
See safety-guardrails.md for detailed rules and recovery patterns.
场景✅ 必须执行❌ 禁止执行
启动Aspire应用
aspire start
在AppHost上执行
dotnet run
等待资源就绪
aspire wait <resource>
使用
curl
/HTTP轮询循环
资源代码变更优先使用资源命令、运行时监视/HMR、仪表板操作或IDE托管调试对锁定文件执行
dotnet build
任务完成
aspire stop
让进程持续运行
检查资源状态
aspire describe
/
aspire ps
手动检查进程
在git工作树中操作
aspire start --isolated
不添加隔离参数直接执行
aspire start
通过AI代理运行为所有命令添加
--non-interactive
参数
假设终端为交互式
编辑不熟悉的API先执行
aspire docs search <topic>
,再执行
aspire docs api search <query>
查找API参考
猜测API结构
检查C# AppHost API(若可用)使用
dotnet-inspect
技能查看本地符号
猜测重载或构建链
添加自定义仪表板/资源命令先执行
aspire docs search "custom resource commands"
未查阅文档就自定义
WithCommand
模式
安装Aspire支持使用
aspire add
aspire init
dotnet workload install aspire
(已废弃)
详细规则和恢复模式请查看safety-guardrails.md

Default Workflow

默认工作流

  1. Confirm workspace is Aspire — identify the AppHost
  2. aspire start
    (or
    aspire start --isolated
    in worktrees)
  3. aspire wait <resource>
    before interacting with any resource
  4. aspire describe
    to inspect state, then work
  5. If AppHost code changed, rerun
    aspire start
    ; if only one resource changed, prefer the resource's commands/watch/HMR/debug workflow
  6. aspire stop
    when cleanup is explicitly requested or needed to release locks/ports
  1. 确认工作区为Aspire项目——识别AppHost
  2. 执行
    aspire start
    (在工作树中执行
    aspire start --isolated
  3. 与任何资源交互前执行
    aspire wait <resource>
  4. 执行
    aspire describe
    检查状态,再开展操作
  5. 若AppHost代码变更,重新执行
    aspire start
    ;若仅单个资源变更,优先使用资源的命令/监视/HMR/调试工作流
  6. 当明确需要清理或释放锁/端口时,执行
    aspire stop

Quick Reference

快速参考

TaskCommand
Start app (agents)
aspire start
(background, preferred)
Start app (human)
aspire run
(foreground, dashboard)
Stop app
aspire stop
Wait for resource
aspire wait <resource>
Check status
aspire ps
or
aspire describe
Show hidden resources (proxies, helpers, migrations)
aspire ps --include-hidden
/
aspire describe --include-hidden
Resource operation
aspire resource <resource-name> <command>
such as
stop
,
start
, or
rebuild
when exposed
Create new project
aspire new aspire-starter
Add Aspire to existing
aspire init
(then hand off to
aspireify
skill for wiring)
Add integration
aspire add <package>
Discover integrations
aspire integration list --format Json
/
aspire integration search <query> --format Json
Upgrade the CLI itself
aspire update --self
Update project package refs
aspire update
(modifies project files — get user approval)
Restore generated files
aspire restore
Environment maintenance
aspire cache clear
,
aspire certs trust
,
aspire certs clean
Diagnose environment
aspire doctor
Machine-readable output
--format Json
(supported:
ps
,
describe
,
start
)
Look up API reference
aspire docs api search <query> --language csharp|typescript
Browse API entries
aspire docs api list <scope>
Get API detail
aspire docs api get <id>
任务命令
启动应用(代理)
aspire start
(后台运行,推荐)
启动应用(人工)
aspire run
(前台运行,带仪表板)
停止应用
aspire stop
等待资源就绪
aspire wait <resource>
检查状态
aspire ps
aspire describe
显示隐藏资源(代理、辅助工具、迁移)
aspire ps --include-hidden
/
aspire describe --include-hidden
资源操作
aspire resource <resource-name> <command>
,例如已暴露的
stop
start
rebuild
创建新项目
aspire new aspire-starter
为现有项目添加Aspire支持
aspire init
(之后交由
aspireify
技能处理连接配置)
添加集成
aspire add <package>
发现集成
aspire integration list --format Json
/
aspire integration search <query> --format Json
升级CLI本身
aspire update --self
更新项目包引用
aspire update
(会修改项目文件——需获得用户批准)
恢复生成的文件
aspire restore
环境维护
aspire cache clear
,
aspire certs trust
,
aspire certs clean
诊断环境
aspire doctor
机器可读输出
--format Json
(支持命令:
ps
,
describe
,
start
查找API参考
aspire docs api search <query> --language csharp|typescript
浏览API条目
aspire docs api list <scope>
获取API详情
aspire docs api get <id>

Error Handling

错误处理

SymptomCauseAction
File lock errors during build (
MSB3491
,
CS2012
)
Aspire is running and holds locks on
bin/
,
obj/
, and assemblies.
Run
aspire stop
first
, then rebuild or
aspire start
. Do NOT conclude the project has a permanent build failure.
"Port already in use"Previous instance running
aspire stop
, then
aspire start
Resource not foundApp not started or name wrong
aspire ps
to check
Build errors in resourceCode error, not Aspire issueFix code, then use resource commands/watch/HMR/debug workflow or rerun
aspire start
if AppHost code changed
Environment issuesMissing SDK or tools
aspire doctor
to diagnose
JSON parse failure from
aspire start
Mixed human/JSON output (#15843)Strip non-JSON lines before parsing
aspire wait
rejects name
Use
displayName
not
name
(#15842)
Use
displayName
from
aspire ps --format Json
aspire ps
hangs
AppHost on breakpoint (#15576)Use timeout, check AppHost process
aspire agent init
fails
Non-interactive terminal (#16264)Run from standard terminal
Docker daemon unavailableContainer-backed resources fail to startStart Docker Desktop, then
aspire start
Multiple AppHosts detectedWrong AppHost targetedUse
--apphost <path>
to specify explicitly
症状原因操作
构建时出现文件锁错误(
MSB3491
,
CS2012
Aspire正在运行,锁定了
bin/
obj/
和程序集文件
先执行
aspire stop
,然后重新构建或执行
aspire start
。请勿判定项目存在永久性构建故障。
"端口已被占用"之前的实例仍在运行
aspire stop
,然后执行
aspire start
资源未找到应用未启动或名称错误执行
aspire ps
检查
资源构建错误代码错误,与Aspire无关修复代码,然后使用资源命令/监视/HMR/调试工作流;若AppHost代码变更,重新执行
aspire start
环境问题缺少SDK或工具执行
aspire doctor
诊断
aspire start
返回JSON解析失败
混合了人工输出和JSON输出(#15843解析前剔除非JSON行
aspire wait
拒绝指定名称
应使用
displayName
而非
name
#15842
使用
aspire ps --format Json
中的
displayName
aspire ps
挂起
AppHost处于断点状态(#15576设置超时,检查AppHost进程
aspire agent init
执行失败
非交互式终端(#16264在标准终端中运行
Docker守护进程不可用基于容器的资源启动失败启动Docker Desktop,然后执行
aspire start
检测到多个AppHost目标AppHost错误使用
--apphost <path>
明确指定

🔒 File-Lock Recovery (MSB3491 / CS2012) — Always
aspire stop
First

🔒 文件锁恢复(MSB3491 / CS2012)—— 务必先执行
aspire stop

When a build fails with
error MSB3491: Could not write to output file ...
or
error CS2012: Cannot open ... for writing
, the project itself is healthy — Aspire is running and holding file locks on the resource's output assemblies. The recovery is always the same:
bash
undefined
当构建失败并提示
error MSB3491: Could not write to output file ...
error CS2012: Cannot open ... for writing
时,项目本身并无问题——Aspire正在运行并锁定了资源的输出程序集。恢复步骤始终如下:
bash
undefined

✅ Correct recovery sequence

✅ 正确恢复流程

aspire stop # release the locks
aspire stop # 释放锁

... then either rebuild / restart one resource if the resource exposes commands ...

... 若资源暴露了命令,可重新构建/重启单个资源 ...

aspire resource <name> rebuild # example: C# project resource with rebuild command
aspire resource <name> rebuild # 示例:带rebuild命令的C#项目资源

... or restart the whole AppHost ...

... 或重启整个AppHost ...

aspire start # if AppHost code changed or Aspire was already stopped

| ❌ NEVER do | ✅ ALWAYS do |
|------------|-------------|
| Tell the user the project has a permanent build failure | Recognize the lock as Aspire holding outputs and run `aspire stop` |
| `dotnet build` again with locks held | `aspire stop` first, then `dotnet build` (or prefer resource commands/watch/HMR/debug workflow) |
| Delete `bin/` / `obj/` to "fix" the lock | `aspire stop` — deletion may succeed but the next build relocks |
| `pkill dotnet` or `kill <PID>` to free locks | `aspire stop` — clean shutdown via the CLI, no orphans |
| Tell the user to "reboot" or "restart your machine" | `aspire stop` — single command, instant fix |

The same rule applies to any "file in use", "cannot access the file", or
"another process is using" error during a build of an Aspire-managed resource.
aspire start # 若AppHost代码已变更或Aspire已停止

| ❌ 禁止操作 | ✅ 必须操作 |
|------------|-------------|
| 告知用户项目存在永久性构建故障 | 识别出是Aspire锁定了输出文件,执行`aspire stop` |
| 在锁存在的情况下再次执行`dotnet build` | 先执行`aspire stop`,再执行`dotnet build`(或优先使用资源命令/监视/HMR/调试工作流) |
| 删除`bin/` / `obj/`来"修复"锁 | 执行`aspire stop`——删除操作可能成功,但下次构建仍会锁定 |
| 使用`pkill dotnet`或`kill <PID>`释放锁 | 执行`aspire stop`——通过CLI优雅关闭,无孤立进程 |
| 告知用户"重启"或"重启机器" | 执行`aspire stop`——单个命令即可快速修复 |

上述规则同样适用于Aspire托管资源构建时出现的任何"文件正在使用"、"无法访问文件"或"其他进程正在使用"错误。

Handoff Rules

移交规则

ScenarioRoute To
AppHost wiring after
aspire init
(scan repo, add resources, ServiceDefaults/OTel)
aspireify
skill (
aspireify/SKILL.md
) or project-local
.agents/skills/aspireify/SKILL.md
Browser logs (
Aspire.Hosting.Browsers
/
WithBrowserLogs()
) and dashboard authoring
aspireify
skill (code edits) and
aspire-monitoring
(discovery)
Custom resource commands (
WithCommand
,
ExecuteCommandResult
,
HttpCommandResultMode
)
aspireify
skill
Lifecycle hooks (
SubscribeBeforeStart
,
SubscribeAfterResourcesCreated
, BeforeStart pipeline phase)
aspireify
skill
Endpoint authoring (
WithEndpoint
updates,
ExcludeReferenceEndpoint
flag)
aspireify
skill
Deploy, publish, pipeline steps,
aspire destroy
aspire-deployment
skill
Logs, traces, metrics, dashboard,
aspire dashboard run
aspire-monitoring
skill
Deployed app diagnostics
azure-diagnostics
skill (azure-skills)
场景移交至
aspire init
后的AppHost连接配置(扫描仓库、添加资源、ServiceDefaults/OTel配置)
aspireify
技能(
aspireify/SKILL.md
)或项目本地的
.agents/skills/aspireify/SKILL.md
浏览器日志(
Aspire.Hosting.Browsers
/
WithBrowserLogs()
)和仪表板创作
aspireify
技能(代码编辑)和
aspire-monitoring
技能(发现)
自定义资源命令(
WithCommand
,
ExecuteCommandResult
,
HttpCommandResultMode
aspireify
技能
生命周期钩子(
SubscribeBeforeStart
,
SubscribeAfterResourcesCreated
, BeforeStart管道阶段)
aspireify
技能
端点创作(
WithEndpoint
更新、
ExcludeReferenceEndpoint
标志)
aspireify
技能
部署、发布、流水线步骤、
aspire destroy
aspire-deployment
技能
日志、追踪、指标、仪表板、
aspire dashboard run
aspire-monitoring
技能
已部署应用的诊断
azure-diagnostics
技能(azure-skills)

Runtime Settings And Environment

运行时设置与环境

VariableDefaultPurpose
ASPIRE_ENABLE_CONTAINER_TUNNEL
true
Container tunnel provides uniform host connectivity across Docker Desktop, Docker Engine, and Podman. Set to
false
to opt out.
ASPIRE_ENVIRONMENT
unsetSelects the environment-specific config profile — controls which
appsettings.{environment}.json
is loaded and which environment is reported in dashboard telemetry.
ASPIRE_DCP_USE_DEVELOPER_CERTIFICATE
true
The Aspire trusted developer certificate is used by DCP on Windows. Set to
false
to opt out.
features.defaultWatchEnabled
false unless configuredEnables Aspire default watch for supported C# and TypeScript AppHosts. Do not treat this as per-resource rebuild, restart, or hot reload for resource source changes.
变量默认值用途
ASPIRE_ENABLE_CONTAINER_TUNNEL
true
容器隧道可在Docker Desktop、Docker Engine和Podman之间提供统一的主机连接。设置为
false
可退出该功能。
ASPIRE_ENVIRONMENT
未设置选择特定环境的配置文件——控制加载哪个
appsettings.{environment}.json
以及仪表板遥测中报告的环境。
ASPIRE_DCP_USE_DEVELOPER_CERTIFICATE
true
Windows系统上的DCP使用Aspire可信开发者证书。设置为
false
可退出该功能。
features.defaultWatchEnabled
除非配置否则为false为受支持的C#和TypeScript AppHost启用Aspire默认监视。请勿将其视为针对资源源码变更的逐资源重建、重启或热重载。

TypeScript AppHost Note

TypeScript AppHost注意事项

Detection covers TS AppHosts (
apphost.ts
), but all TS AppHost authoring is delegated to
aspireify
. Current rules to apply when handing off:
RuleWhy
Prefer unified
withEnvironment(name, value)
over deprecated per-kind helpers (
withEnvironmentEndpoint
,
withEnvironmentParameter
,
withEnvironmentConnectionString
,
withEnvironmentExpression
,
withEnvironmentFromOutput
,
withEnvironmentFromKeyVaultSecret
)
Per-kind helpers are deprecated — single API now handles all value types
Never edit
.aspire/modules/
directly
Generated; use
aspire add <package>
to regenerate and
aspire restore
to recover missing files
Use
aspire docs api search <query> --language typescript
for API lookup
TS surface differs from C#
本技能可检测TS AppHost(
apphost.ts
),但所有TS AppHost创作工作均委托给
aspireify
技能
。移交时需遵循以下规则:
规则原因
优先使用统一的
withEnvironment(name, value)
,而非已废弃的按类型划分的辅助方法(
withEnvironmentEndpoint
,
withEnvironmentParameter
,
withEnvironmentConnectionString
,
withEnvironmentExpression
,
withEnvironmentFromOutput
,
withEnvironmentFromKeyVaultSecret
按类型划分的辅助方法已废弃——单个API现在可处理所有值类型
切勿直接编辑
.aspire/modules/
目录
该目录为生成目录;使用
aspire add <package>
重新生成,使用
aspire restore
恢复缺失文件
使用
aspire docs api search <query> --language typescript
查找API
TS接口与C#不同

Skill Routing — In-Plugin Sibling Skills

技能路由——插件内同级技能

After
aspire init
drops a skeleton AppHost +
aspire.config.json
, route AppHost wiring (scan repo → propose resource graph → edit AppHost → wire
Aspire.ServiceDefaults
/ OTel → validate via
aspire start
) to the in-plugin aspireify skill:
aspireify/SKILL.md
. For first-run flows that only need the skeleton drop, see the in-plugin aspire-init skill:
aspire-init/SKILL.md
. This orchestration skill stays focused on lifecycle (start/stop/wait/restart) and never edits AppHost code itself.
aspire init
生成基础AppHost +
aspire.config.json
后,将AppHost连接配置工作(扫描仓库→提议资源图→编辑AppHost→配置
Aspire.ServiceDefaults
/OTel→通过
aspire start
验证)移交至插件内的aspireify技能:
aspireify/SKILL.md
。对于仅需生成基础框架的首次运行流程,请查看插件内的aspire-init技能:
aspire-init/SKILL.md
。本编排技能专注于生命周期管理(启动/停止/等待/重启),绝不编辑AppHost代码。

Project-Local Skill Precedence

项目本地技能优先级

If
.agents/skills/aspire/SKILL.md
exists (from
aspire agent init
), defer to it for: C# AppHost editing, TS AppHost editing, Playwright handoff, investigation workflows. Safety guardrails from this plugin ALWAYS apply.
If
.agents/skills/aspireify/SKILL.md
exists project-locally (installed by
aspire init
in current Aspire), warn the user that a project-local aspireify skill is present and defer to it for AppHost wiring instead of the in-plugin sibling. Same precedence rule as the project-local
aspire
skill above: project-local wins, plugin guardrails still apply.
若存在
.agents/skills/aspire/SKILL.md
(由
aspire agent init
生成),则在以下场景中优先使用该本地技能:C# AppHost编辑、TS AppHost编辑、Playwright移交、调查工作流。本插件的安全防护规则始终适用。
若项目本地存在
.agents/skills/aspireify/SKILL.md
(由当前Aspire版本的
aspire init
安装),需告知用户存在项目本地的aspireify技能,并优先使用该本地技能处理AppHost连接配置,而非插件内的同级技能。优先级规则与上述项目本地
aspire
技能相同:项目本地技能优先,插件防护规则仍适用。

References

参考文档

  • safety-guardrails.md — Detailed rules and recovery patterns
  • detection.md — Project fingerprinting
  • app-commands.md — App lifecycle and bootstrap commands
  • resource-management.md — Resource wait, restart, and operations
  • agent-workflows.md — Common agent investigation, integration, TypeScript, and handoff workflows
  • safety-guardrails.md —— 详细规则和恢复模式
  • detection.md —— 项目指纹识别
  • app-commands.md —— 应用生命周期和引导命令
  • resource-management.md —— 资源等待、重启和操作
  • agent-workflows.md —— 常见代理调查、集成、TypeScript和移交工作流