Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Implements the first part of the spec mentioned in:

* "Pre-run evaluation"
* If the project is multi-targeted, containing the
`$(TargetFrameworks)` property _and_ that property has more than
one item in it, and `-f` was not supplied...
* Prompt the user to select from a list of the
`$(TargetFrameworks)`
* Non-interactive mode will give a friendly error message,
suggesting to supply the `-f` property, listing available target
frameworks in the project.

Add interactive target framework selection to dotnet run

When running a multi-targeted project without specifying --framework, dotnet run now:

  • Prompts interactively (using Spectre.Console) to select a framework with arrow keys

  • Shows a formatted error list in non-interactive mode with available frameworks

  • Handles selection early before project build/evaluation

  • Removes redundant multi-TFM error checking from ThrowUnableToRunError()

  • Adds a few unit tests to validate these changes.

This is currently WIP, as it introduces a "pre-built" Spectre.Console that I will need to setup in source-build in a PRs elsewhere.

Implements the first part of the spec mentioned in:

https://github.com/dotnet/sdk/blob/522c88a6abfc4a011556f839d15844d07ba62cd9/documentation/specs/dotnet-run-for-maui.md?plain=1#L35-L46

Add interactive target framework selection to `dotnet run`

When running a multi-targeted project without specifying
`--framework`, `dotnet run` now:

* Prompts interactively (using `Spectre.Console`) to select a framework
  with arrow keys

* Shows a formatted error list in non-interactive mode with available
  frameworks

* Handles selection early before project build/evaluation

* Removes redundant multi-TFM error checking from
  `ThrowUnableToRunError()`

* Adds a few unit tests to validate these changes.

This is currently WIP, as it introduces a "pre-built"
`Spectre.Console` that I will need to setup in source-build in a PRs
elsewhere.
There are other tests that do this
This test fails after I made it check TF at runtime.

This was not even the existing behavior, I think we can remove this test.
jonathanpeppers added a commit to jonathanpeppers/spectre.console that referenced this pull request Oct 29, 2025
Context: dotnet/sdk#51430
Context: dotnet/source-build-reference-packages#1447

We would like to use Spectre.Console for the `dotnet` CLI, and .NET has
to be able to be completely built from source.

It would help us to have `PolySharp` only included when building for
`netstandard2.0`, as that is the only target framework that needs the
polyfills.

.NET would probably only use the latest target framework.

Thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants