Skip to content

Start the beginning of AOT'ing the Aspire.Cli. - #9841

Merged
David Fowler (davidfowl) merged 7 commits into
microsoft:mainfrom
eerhardt:AotCli
Jun 17, 2025
Merged

Start the beginning of AOT'ing the Aspire.Cli.#9841
David Fowler (davidfowl) merged 7 commits into
microsoft:mainfrom
eerhardt:AotCli

Conversation

@eerhardt

@eerhardtEric Erhardt (eerhardt) commented Jun 11, 2025

Copy link
Copy Markdown
Member

This is the initial work to getting the Aspire.Cli AOT'd.

Don't use Tuples on the wire. Instead always use strong, named types. This does not require a baseline capability version bump becuase we already bumped it for 9.4 in #9400.

With more work and depending on microsoft/vs-streamjsonrpc#1196 I got this working locally:

image

The aspire.exe is about 12 MB today and starts basically immediately.

@eerhardtEric Erhardt (eerhardt) changed the title (Draft) Start the beginning of AOT'ing the Aspire.Cli.Start the beginning of AOT'ing the Aspire.Cli.Jun 17, 2025
@eerhardt
Eric Erhardt (eerhardt) marked this pull request as ready for review June 17, 2025 15:17
CopilotAI review requested due to automatic review settings June 17, 2025 15:17

This comment was marked as outdated.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR initiates the work to AOT the Aspire.Cli by replacing tuple usage with strong, named types for RPC data structures and streamlining related dependencies.

  • Replace tuples with strongly typed objects in both hosting and CLI backchannel areas.
  • Remove the now unused CliRpcTarget dependency.
  • Update configuration files and package versions to support AOT and improved RPC compatibility.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
tests/Aspire.Cli.Tests/Utils/CliTestHelper.csRemoved CliRpcTarget dependency to match production code changes.
src/Aspire.Hosting/Backchannel/AppHostRpcTarget.csChanged RPC method return types from tuples to strong types.
src/Aspire.Cli/Program.csRemoved CliRpcTarget registration from DI in CLI startup.
src/Aspire.Cli/Backchannel/AppHostBackchannel.csUpdated RPC handling and conversion from strong types to tuples.
src/Aspire.Cli/Backchannel/BackchannelDataTypes.csIntroduced strongly typed backchannel data objects for CLI.
src/Aspire.Cli/Aspire.Cli.csprojUpdated shared file references for consistency.
Directory.Packages.propsUpgraded StreamJsonRpc version to support latest functionality.
Comments suppressed due to low confidence (4)

tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs:173

  • The removal of CliRpcTarget from production code should be consistently reflected in tests. Ensure tests are updated to no longer rely on CliRpcTarget registration.
 var logger = serviceProvider.GetRequiredService<ILogger<AppHostBackchannel>>();

src/Aspire.Hosting/Backchannel/AppHostRpcTarget.cs:26

  • Ensure that all consumers of GetPublishingActivitiesAsync are updated to handle PublishingActivityState instead of tuple return values.
 public async IAsyncEnumerable<PublishingActivityState> GetPublishingActivitiesAsync([EnumeratorCancellation] CancellationToken cancellationToken)

src/Aspire.Hosting/Backchannel/AppHostRpcTarget.cs:107

  • Confirm that all RPC consumers are updated to use DashboardUrlsState in place of tuple-based dashboard URLs.
 public Task<DashboardUrlsState> GetDashboardUrlsAsync()

src/Aspire.Cli/Backchannel/AppHostBackchannel.cs:168

  • Ensure that converting PublishingActivityState to a tuple preserves type safety and that all consumers of this method are adjusted accordingly.
 state.IsError);

<PackageVersion Include="System.IO.Hashing" Version="9.0.4" />
<PackageVersion Include="Yarp.ReverseProxy" Version="2.3.0" />
<PackageVersion Include="StreamJsonRpc" Version="2.21.69" />
<PackageVersion Include="StreamJsonRpc" Version="2.22.11" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I understanding correctly then that this new version is now AOT friendly? (meaning the branch that was WIP in their repo has now merged to main?)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This new version doesn't include a bunch of changes in StreamJsonRpc that are needed. I'm working with Andrew Arnott (@AArnott) to get all the necessary changes in main and then ship a "preview" package with them in.

We will use the "preview" package just from the CLI. The AppHost will continue to reference the latest released stable version. The two versions will be compatible. And the CLI can use a "preview" package because we package the code and will AOT it in our released executable. We don't need to reference a stable version like we do in our libraries.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! thanks Eric Erhardt (@eerhardt)!

@davidfowl
David Fowler (davidfowl) enabled auto-merge (squash) June 17, 2025 20:29
@davidfowl
David Fowler (davidfowl) merged commit 215ae98 into microsoft:mainJun 17, 2025
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 18, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@eerhardt@davidfowl@joperezr