.NET Aspire  

HOWTO: Upgrade Aspire from .NET 9 to .NET 10 CPM Solutions

I recently had to upgrade a .NET 9 Solution to .NET 10 that had been wired up with .NET Aspire. The Solution was a .SLN file containing multiple projects registered with Aspire.

However, there was a unique challenge:

  • All the Projects had been configured with Central Package Management (CPM) - where the NuGet Package Versions are mapped in a directory.packages.props file

The official Documentation (Upgrade to Aspire 13.0) states that there are breaking changes to ASPIRE. .NET 9 projects .NET 9 projects use ASPIRE 13.x, while .NET 10 uses 18.x. The steps in the documentation only cover how to upgrade projects that have their NuGet Package Versions mapped within their respective Project file.

The steps are different if one has to upgrade Solutions using the Central Package Management.

Since I didn't find any documentation around it, I thought jotting it down here could help someone. In fact, even the Upgrade Assistant doesn't help. Neither does ChatGPT, Perplexity, GitHub Co-Pilot in Visual Studio, nor the Upgrade Assistant Tool mentioned in the documentation help.

It's just two steps:

Step 1: Upgrade the Aspire AppHost Project

Previously, in the .NET 9 Aspire Project AppHost.csproj file:

<Project Sdk="Microsoft.NET.Sdk">                                    <--- change this

  <Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />                   <--- remove this

  <PropertyGroup>
     ....
     <TargetFramework>net9.0</TargetFramework>                        <--- change this to 10.0
     <IsAspireHost>true</IsAspireHost>                                <--- remove this
  </PropertyGroup>

  <ItemGroup>                                                         <--- remove this
     <PackageReference Include="Aspire.Hosting.AppHost" />            <--- remove this
  </ItemGroup>                                                        <--- remove this

  <ItemGroup>
     <ProjectReference Include="....." />
     ....
  </ItemGroup>

</Project>

Now, in the .NET 10 Aspire Project AppHost.csproj file, the changed lines:

<Project Sdk="Aspire.AppHost.Sdk/13.0.0">
   ...
     <TargetFramework>net10.0</TargetFramework>
   ...

Step 2: Upgrade the Solution's Central Package Management (CPM)

Previously, in .NET 9 the directory.packages.props file looked like this:

<Project>
  <PropertyGroup>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
  </PropertyGroup>
  <ItemGroup>
    <PackageVersion Include="Aspire.Hosting.AppHost" Version="9.5.2" />                        <-- remove this
    <PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.10.0" />         <-- change this
    <PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="9.5.2" />         <-- change this
    ....

In .NET 10, the directory.packages.props file, the changed lines:

   <PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="10.1.0" />
    <PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="10.1.0" />

That's it!

Don't forget to Clean the Solution, and Rebuild.

Hope this helps someone!