Skip to content

File-based apps: recognize more logger arguments - #54637

Merged
jjonescz merged 9 commits into
dotnet:release/10.0.4xxfrom
jjonescz:54540-sprint-unknown-tokens
Jun 25, 2026
Merged

jjonescz merged 9 commits into
dotnet:release/10.0.4xxfrom
jjonescz:54540-sprint-unknown-tokens

Conversation

@jjonescz

@jjonescz jjonescz commented Jun 8, 2026 •

Copy link
Copy Markdown
Member

Fixes #51809.
Fixes #54715.

First commit also improves the error message for unknown args (see #54540 (comment)).

cc @baronfel

@jjonescz
jjonescz requested a review from Copilot June 8, 2026 13:05
@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Jun 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes file-based app argument handling so MSBuild logger-related switches (notably terminal logger args like -tl:off) no longer prevent file-based app detection for dotnet build/clean/publish/run, and improves the fallback warnings by surfacing which arguments caused fallback to MSBuild.

Changes:

  • Added logger-argument separation (-tl*, -tlp*, -clp*, --terminalLogger*, --consoleLoggerParameters*, plus existing binlog args) and used it in file-based app routing.
  • Enhanced file-based fallback warnings to include the unsupported/unrecognized arguments list, and updated localization resources accordingly.
  • Added/updated tests covering logger-argument forms and warning output expectations.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/dotnet.Tests/LoggerUtilityTests.cs New unit tests for recognizing/normalizing logger argument forms.
test/dotnet.Tests/CommandTests/Run/RunFileTests_General.cs Adds coverage for duplicate file-path args in run and updates warning assertions to include unsupported arg lists.
test/dotnet.Tests/CommandTests/Run/RunFileTests_BuildOptions.cs Adds end-to-end tests ensuring logger args don’t break file-based run/build paths and are not forwarded to the app.
src/Cli/dotnet/LoggerUtility.cs Introduces generalized logger-argument recognition and separation (beyond binlog).
src/Cli/dotnet/Commands/Run/RunCommand.cs Uses the new logger-argument separation when building msbuild-forwarded args for dotnet run.
src/Cli/dotnet/Commands/CommandFactory.cs Uses logger-argument separation for file-based app detection and enriches fallback warnings with arg lists.
src/Cli/dotnet/Commands/CliCommandStrings.resx Updates warning strings to include unsupported/unrecognized arguments.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hant.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.zh-Hans.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.tr.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.ru.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.pt-BR.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.pl.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.ko.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.ja.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.it.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.fr.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.es.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.de.xlf Localization update for modified warning strings.
src/Cli/dotnet/Commands/xlf/CliCommandStrings.cs.xlf Localization update for modified warning strings.

@jjonescz
jjonescz marked this pull request as ready for review June 19, 2026 04:26
@jjonescz
jjonescz requested a review from a team June 19, 2026 04:26
@jjonescz

Copy link
Copy Markdown
Member Author

@333fred @RikkiGibson for reviews, thanks

Comment on lines +952 to +953
out List<string> loggerArgs,
out List<string> nonLoggerArgs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do these really need to be lists? Can they be IA?

new FileInfo(binaryLogPath).Should().NotExist();
}

[Theory]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

-fl tests? -noconsolelogger?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

@jjonescz

Copy link
Copy Markdown
Member Author

@RikkiGibson for a second review
@dotnet/dotnet-cli @ellahathaway fyi, this affects project-based dotnet run too

if (!TryCountApplicationArgumentsBeforeDoubleDash(applicationArguments, applicationArgumentsAfterDoubleDash, out var countBeforeDoubleDash))
{
// This hopefully should not happen, but if it does, we don't want to break users.
Reporter.Error.WriteLine("Warning: Could not determine which application arguments appeared after '--'. All application arguments will be passed to the application without treating logger arguments specially.".Yellow());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The fallback warning in SeparateApplicationLoggerArguments is an inline English literal written to Reporter.Error, bypassing CliCommandStrings.resx/.xlf. Non-English users would get an untranslated message.

@jjonescz jjonescz Jun 25, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, but this is more like an assert, it should not happen as far as I'm aware (on the other hand I'm not 100% confident of it, and it could break if System.CommandLine changes behavior, so it felt safer to have a warning + fallback). So I can move it to resx anyway.

Comment on lines +921 to +922
Debug.Assert(nonLoggerArgs[0] == "-");
nonLoggerArgs = nonLoggerArgs.SetItem(0, entryPointFilePath);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nonLoggerArgs = nonLoggerArgs.SetItem(0, entryPointFilePath); is never read again. The command passes the separate args array to applicationArgs, and args already had - stripped and the temp path is passed separately via entryPointFileFullPath. Drop line 922, keep the Debug.Assert invariant.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, thanks, looks like that was a pre-existing issue with nonBinLogArgs too.

@jjonescz
jjonescz requested a review from ellahathaway June 25, 2026 12:30
@jjonescz
jjonescz merged commit d760482 into dotnet:release/10.0.4xx Jun 25, 2026
28 checks passed
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.

4 participants