Skip to content

Allow skipping project fallback with file-based run #49808

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

Merged
merged 1 commit into from
Jul 23, 2025

Conversation

jjonescz
Copy link
Member

Resolves #49790.

@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Jul 16, 2025
@jjonescz jjonescz marked this pull request as ready for review July 16, 2025 14:19
@jjonescz jjonescz requested review from Copilot and a team July 16, 2025 14:19
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 introduces a --file option to the dotnet run command, allowing users to explicitly specify a file-based app to run and skip project fallback behavior. This addresses GitHub issue #49790 by providing a way to run file-based apps even when a project exists in the current directory.

Key changes include:

  • Added new --file option to the run command with appropriate validation
  • Updated file-based app execution logic to use the new option format internally
  • Added comprehensive test coverage for the new functionality

Reviewed Changes

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

Show a summary per file
File Description
src/Cli/dotnet/Commands/Run/RunCommandParser.cs Adds the new --file option definition
src/Cli/dotnet/Commands/Run/RunCommand.cs Implements logic for handling the --file option and validation
src/Cli/dotnet/Program.cs Updates file-based app parsing to use --file option format
src/Cli/dotnet/Commands/CliCommandStrings.resx Adds localization strings for the new option
test/dotnet.Tests/CommandTests/Run/RunFileTests.cs Adds test coverage for the new functionality
documentation/general/dotnet-run-file.md Updates documentation to reflect the new option
Multiple .xlf files Adds localization entries for all supported languages
Multiple completion snapshot files Updates shell completion scripts

@jjonescz
Copy link
Member Author

@RikkiGibson @jaredpar for reviews, thanks

@jjonescz
Copy link
Member Author

@RikkiGibson @333fred for reviews, thanks

.Should().Pass()
.And.HaveStdOutContaining("""
Hello from Program
""");
Copy link
Member

Choose a reason for hiding this comment

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

So the fact that there is no "echo args" in the output means we ran the file rather than running the project? Is that right?

Copy link
Member Author

@jjonescz jjonescz Jul 23, 2025

Choose a reason for hiding this comment

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

The project cannot even run, it has no source files (only a project file). If it could run, it should print Hello from App instead of Hello from Program. And yes, there would be also echo args.

@jjonescz jjonescz merged commit be1e743 into dotnet:main Jul 23, 2025
30 checks passed
@jjonescz jjonescz deleted the sprint-fallback branch July 23, 2025 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-run-file Items related to the "dotnet run <file>" effort
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running file-based app using repo-local dotnet install performs restore for .proj file in root of repo
4 participants