Skip to content

WithArgs runs on startup even if WithExplicitStart is called on a service in 13.4.0 #17813

@aL3891

Description

@aL3891

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

After upating to 13.4.0, The callback passed to WithArgs() runs on startup even though WithExplicitStart() is specified on the service. In my case this causes a few popup from services to appear, asking for values.
Supplying a value does not actually start the service though and starting the service manually does result in the WithArgs callback being run again.
More specifically, it runs when the dashboard is opened for the first time, so right away when launching with the debugger and when opening the dashboard when just doing aspire run

Expected Behavior

Previously, the WithArgs method did not run at all until the service was started.
after updating, it runs on startup of the dashboard.

Steps To Reproduce

I have a service for adding a migration that looks like this

using Microsoft.Extensions.DependencyInjection;
#pragma warning disable ASPIREINTERACTION001

var builder = DistributedApplication.CreateBuilder(args);
builder.AddExecutable("AddMigration", "dotnet", "", "ef", "migrations", "add")
  .WithExplicitStart()
  .WithArgs(async context =>
  {
      var interactionService = context.ExecutionContext.ServiceProvider.GetRequiredService<IInteractionService>();
      var name = await interactionService.PromptInputAsync("AddMigrations", "Enter Migation Name", new()
      {
          Name = "Migation Name",
          InputType = InputType.Text,
          Required = true,
          Placeholder = "New migration"
      });

      if (name.Canceled)
          throw new OperationCanceledException("Canceled");
      context.Args.Add(name.Data.Value);
  });

builder.Build().Run();

This used to only ask for a migration name if that service was started explicitly from the dashboard

Exceptions (if any)

No response

Aspire doctor output

Aspire Environment Check

Aspire
✅ Aspire CLI version 13.4.0 (channel: stable)

AppHost
✅ AppHost version 13.4.0 (Mma.AppHost\Mma.AppHost.csproj)

.NET SDK
✅ .NET 11.0.100-preview.4.26230.115 installed (x64)

Container Runtime
✅ Podman v5.8.2: running (configured via ASPIRE_CONTAINER_RUNTIME=podman) ← active

Environment
✅ HTTPS development certificate is trusted

Summary: 5 passed, 0 warnings, 0 failed

Aspire CLI Installations

╭──────────────────────────────────────────────┬─────────────────────────────────────────────────┬─────────┬───────────┬─────────────╮
│ Path │ Version │ Channel │ Route │ PATH status │
├──────────────────────────────────────────────┼─────────────────────────────────────────────────┼─────────┼───────────┼─────────────┤
│ C:\Users\aL.aspire\bin\aspire.exe (current) │ 13.4.0+becb48e2d61099e35ae336d527d3875e928d6594 │ stable │ (unknown) │ active │
╰──────────────────────────────────────────────┴─────────────────────────────────────────────────┴─────────┴───────────┴─────────────╯

Anything else?

No response

Metadata

Metadata

Assignees

Labels

area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplicationtriage:bot-seenAspire triage bot has seen this issue‼️regression-from-last-releaseThis used to work in an earlier version of Aspire and we broke it!

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions