Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 11, 2025

This PR backports the changes from #11951 to ensure consistent behavior between single-file and multi-file AppHost project runs in the Aspire CLI.

Changes

DotNetCliRunner.cs

  • Single-file project support: Updated the single-file project run command to include the noProfileSwitch argument, aligning behavior with multi-file projects
  • Improved argument handling: Changed from using the project file as a positional argument to using the --file flag for single-file projects
  • Argument filtering: Added logic to filter out empty or whitespace-only arguments from the CLI args array, preventing invalid command-line arguments from being passed to dotnet run

Before:

true => ["run", projectFile.FullName, "--", ..args]

After:

true => ["run", noProfileSwitch, "--file", projectFile.FullName, "--", .. args]

And added:

cliArgs = [.. cliArgs.Where(arg => !string.IsNullOrWhiteSpace(arg))];

DotNetCliRunnerTests.cs

  • Fixed indentation and removed trailing whitespace throughout the file
  • Updated AddPackageAsyncUseFilesSwitchForSingleFileAppHost test to enable the SingleFileAppHostEnabled feature
  • Added 3 new test methods:
    • RunAsyncAppliesNoLaunchProfileForSingleFileAppHost - Validates that --no-launch-profile is included when specified
    • RunAsyncDoesNotIncludeNoLaunchProfileForSingleFileAppHostWhenNotSpecified - Validates the flag is omitted when not specified
    • RunAsyncFiltersOutEmptyArgumentsForSingleFileAppHost - Validates that empty arguments are properly filtered out

Testing

All 386 CLI tests pass successfully with these changes, confirming no regressions were introduced.

Note

The original PR #11951 included additional tests that depend on features (Debug property, nonInteractiveSwitch, and verboseSwitch) not present in the target branch. This backport includes only the compatible changes while maintaining the core functionality improvements.

Original prompt

Backport @dotnet/aspire/pull/11951


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…nd and filter empty arguments

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copilot AI changed the title [WIP] Backport pull request #11951 for dotnet/aspire Backport PR #11951: Add noProfileSwitch to run command in DotNetCliRunner Oct 11, 2025
Copilot AI requested a review from davidfowl October 11, 2025 05:29
Copilot finished work on behalf of davidfowl October 11, 2025 05:29
@github-actions
Copy link
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11959

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11959"

1 similar comment
@github-actions
Copy link
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11959

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11959"

@davidfowl davidfowl marked this pull request as ready for review October 14, 2025 04:44
Copilot AI review requested due to automatic review settings October 14, 2025 04:44
Copy link
Contributor

Copilot AI left a comment

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 backports changes from #11951 to improve the consistency of the dotnet run command behavior between single-file and multi-file AppHost projects in the Aspire CLI.

  • Updated single-file project run command to include the noProfileSwitch parameter and use --file flag instead of positional argument
  • Added argument filtering to remove empty or whitespace-only arguments from the CLI command array
  • Enhanced test coverage with three new test methods to validate the changes

Reviewed Changes

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

File Description
src/Aspire.Cli/DotNet/DotNetCliRunner.cs Updated single-file project run command construction and added empty argument filtering
tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs Added feature enablement to existing test and three new test methods for single-file AppHost scenarios

@joperezr joperezr merged commit 287fe54 into release/9.5 Oct 17, 2025
315 of 317 checks passed
@OptimusPi
Copy link
Contributor

"🚀 Dogfood this PR with:"

What is Dogfood?

This was referenced Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants