Skip to content

[CLI] Add --framework option to aspire new #9985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matthebrown
Copy link
Contributor

@matthebrown matthebrown commented Jun 22, 2025

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #9931

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@Copilot Copilot AI review requested due to automatic review settings June 22, 2025 21:39
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jun 22, 2025
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 adds a --framework option to the aspire new command so that users can specify a target framework when scaffolding new projects.

  • Introduces a nullable --framework CLI option and propagates it through parsing and into the dotnet new invocation.
  • Updates the IDotNetCliRunner interface, its real implementation, and the test stub to include the optional framework parameter.
  • Adds resource entries and translations for the new argument, and a test verifying that the framework value is passed correctly.

Reviewed Changes

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

Show a summary per file
File Description
src/Aspire.Cli/Commands/NewCommand.cs Added --framework CLI option with description
src/Aspire.Cli/Templating/DotNetTemplateFactory.cs Read framework from parse result and pass it to the runner
src/Aspire.Cli/DotNetCliRunner.cs Extended NewProjectAsync to include framework in CLI args
tests/Aspire.Cli.Tests/TestServices/TestDotNetCliRunner.cs Adjusted test stub signature to accept the framework parameter
tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs Added test for framework propagation
src/Aspire.Cli/Resources/NewCommandStrings.resx & .xlf Added FrameworkArgumentDescription and translations
Files not reviewed (1)
  • src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs: Language not supported
Comments suppressed due to low confidence (3)

tests/Aspire.Cli.Tests/TestServices/TestDotNetCliRunner.cs:18

  • The NewProjectAsyncCallback delegate signature omits the extraArgs parameter, so any additional CLI flags are ignored in tests; consider adding a string[] extraArgs parameter after framework to mirror the production signature.
    public Func<string, string, string, string?, DotNetCliRunnerInvocationOptions, CancellationToken, int>? NewProjectAsyncCallback { get; set; }

src/Aspire.Cli/Templating/DotNetTemplateFactory.cs:200

  • [nitpick] Using a literal string to retrieve the option value can be fragile; consider storing the Option<string?> instance in a field and using parseResult.GetValueForOption(frameworkOption) to tie it directly to the declared option.
            var framework = parseResult.GetValue<string?>("--framework");

tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs:574

  • You added a test for when a framework is specified; consider adding a complementary test to verify that, when no --framework flag is provided, the default (null or empty) framework value is passed through correctly.
    [Fact]

@davidfowl
Copy link
Member

I'm not sure we want this change.

@mitchdenny
Copy link
Member

@davidfowl I was talking to @DamianEdwards and @maddymontaquila about this. I think we resolved that did want to ask what the target framework should be somewhere in the flow of questions. We would want the latest stable build to be the default, but allow us to choose 8.0 or 10.0 preview too.

@davidfowl
Copy link
Member

Did we decide that we are going to flow options wholestale to the template provider?

@mitchdenny
Copy link
Member

Well, I think that there are two things here. I think we agreed that aspire new should really be primarily an interactive experience. So to that end adding the --framework option goes against that - however prompting for the framework version would be good, especially being able to choose version 10 (which wouldn't be the default - but still desirable to choose).

@davidfowl
Copy link
Member

I'm ok with prompting for the framework. I was more worried that we didn't have a plan for flowing arguments cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-cli community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[AspireE2E] Cannot create an Aspire project with target net10.0 using aspire new.
3 participants