Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 26, 2025

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original issue description:

Try adding an aspire hosting integration using aspire add {id} -s {source}. The package source is added only when doing the package search but isn't added when calling the package add command. We should preserve the source argument in both commands.

Relevant files: src/Aspire.Cli/Commands/AddCommand.cs

Fixes #9508.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@davidfowl
Copy link
Member

@copilot add a test to tests/Aspire.Cli.Tests/Commands/AddCommandTests.cs that verifies a call to add with the source flows to both search and add.

Copy link
Contributor Author

Copilot AI commented May 26, 2025

@copilot add a test to tests/Aspire.Cli.Tests/Commands/AddCommandTests.cs that verifies a call to add with the source flows to both search and add.

I've added a test that verifies the source parameter flows correctly to both the search and add commands. The test checks that when providing a custom source URL with the --source parameter, the same source is used in both operations. You can see the implementation in commit b738103.

Copilot finished work on behalf of davidfowl May 26, 2025 07:37
@davidfowl davidfowl requested a review from mitchdenny May 26, 2025 07:47
@davidfowl davidfowl marked this pull request as ready for review May 26, 2025 07:58
@davidfowl davidfowl requested review from Copilot and davidfowl May 26, 2025 07:58
Copy link
Contributor

@Copilot 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 ensures that the --source argument is preserved when running both the search and add steps of aspire add -s.

  • Extended AddPackageAsync in IDotNetCliRunner and its implementation to accept a nullable nugetSource.
  • Updated the DotNetCliRunner to include --source when adding packages.
  • Added a new integration test to verify that the source is propagated in both commands.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/Aspire.Cli/DotNetCliRunner.cs Extended CLI runner to pass through --source to dotnet add package.
src/Aspire.Cli/Commands/AddCommand.cs Forwarded the source parameter to the updated AddPackageAsync call.
tests/Aspire.Cli.Tests/TestServices/TestDotNetCliRunner.cs Updated test runner callback signature to include nugetSource.
tests/Aspire.Cli.Tests/Commands/AddCommandTests.cs Added a test case to verify that the source argument is used in both search and add commands.
Comments suppressed due to low confidence (1)

tests/Aspire.Cli.Tests/Commands/AddCommandTests.cs:481

  • Consider adding a complementary test to verify behavior when no --source is provided, ensuring the nugetSource parameter remains null and no --source flag is passed to the runner.
public async Task AddCommandPreservesSourceArgumentInBothCommands()

cliArgsList.Add(nugetSource);
}

string[] cliArgs = [.. cliArgsList];
Copy link
Preview

Copilot AI May 26, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using cliArgsList.ToArray() instead of the C#12 collection spread syntax for clarity and consistency with existing code patterns.

Suggested change
string[] cliArgs = [.. cliArgsList];
string[] cliArgs = cliArgsList.ToArray();

Copilot uses AI. Check for mistakes.

@davidfowl davidfowl changed the title [WIP] The --source argument is not preserved when running aspire add -s The --source argument is not preserved when running aspire add -s May 26, 2025
@davidfowl davidfowl merged commit abb0dad into main May 26, 2025
254 checks passed
@davidfowl davidfowl deleted the copilot/fix-9508 branch May 26, 2025 08:38
@github-actions github-actions bot locked and limited conversation to collaborators Jun 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The --source argument is not preserved when running aspire add -s
3 participants