一键导入
aspire-apphost-setup
Pattern for adding .NET Aspire AppHost and ServiceDefaults to an existing .NET solution
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Pattern for adding .NET Aspire AppHost and ServiceDefaults to an existing .NET solution
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | aspire-apphost-setup |
| description | Pattern for adding .NET Aspire AppHost and ServiceDefaults to an existing .NET solution |
| domain | infrastructure |
| confidence | low |
| source | earned |
When adding .NET Aspire orchestration to an existing .NET solution, there are version-specific SDK patterns and common pitfalls around package compatibility.
For Aspire SDK 9.x (targeting .NET 9), use Microsoft.NET.Sdk as the top-level SDK with a child <Sdk> element:
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.2" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyApp\MyApp.csproj" />
</ItemGroup>
</Project>
The Aspire.AppHost.Sdk 9.x does NOT auto-import Microsoft.NET.Sdk (it only does so for file-based apps where FileBasedProgram=true).
From SDK 13.0.0+, the top-level Sdk="Aspire.AppHost.Sdk/13.x.x" works because it unconditionally imports Microsoft.NET.Sdk.
Keep all Aspire-related packages within the same minor version:
The ServiceDefaults project is a shared library (IsAspireSharedProject=true) that configures OTel, resilience, and service discovery. It references Microsoft.AspNetCore.App as a FrameworkReference.