Skip to content

Support binlog in build/restore of file-based programs #49009

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 2 commits into from
Jun 10, 2025

Conversation

jjonescz
Copy link
Member

@jjonescz jjonescz commented May 16, 2025

Without this PR, dotnet build -bl Program.cs is not supported because both args (-bl and Program.cs) are treated as the "project file" argument (that's a pre-existing behavior, even for project-based programs, but for them all unknown arguments are forwarded to msbuild.exe, which we can't do when using msbuild APIs). This PR makes build/restore extract -bl arguments just like the dotnet run command does.

@jjonescz jjonescz requested a review from a team May 16, 2025 10:44
@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label May 16, 2025
@jjonescz jjonescz marked this pull request as ready for review May 16, 2025 14:42
@Copilot Copilot AI review requested due to automatic review settings May 16, 2025 14:42
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 support for handling the "-bl" (binary log) argument for file-based programs during dotnet build and restore operations.

  • Adds a new utility method to separate binary log arguments.
  • Refactors command parsing in the Run, Restore, and Build commands to use the new utility.
  • Updates test cases to validate the new behavior.

Reviewed Changes

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

Show a summary per file
File Description
test/dotnet.Tests/CommandTests/Run/RunFileTests.cs Adds tests to validate binary log argument handling for build/restore commands.
src/Cli/dotnet/LoggerUtility.cs Introduces a new method to separate binary log arguments from other arguments.
src/Cli/dotnet/Commands/Test/MSBuildUtility.cs Refactors token separation using the new utility method.
src/Cli/dotnet/Commands/Run/RunCommand.cs Updates binary log argument separation to improve consistency.
src/Cli/dotnet/Commands/Restore/RestoreCommand.cs Adjusts processing of file arguments and binary log arguments for restore scenarios.
src/Cli/dotnet/Commands/Build/BuildCommand.cs Similar refactoring and merging of binary log arguments during build command parsing.

@@ -61,6 +61,23 @@ private static FacadeLogger ConfigureDispatcher(List<BinaryLogger> binaryLoggers
return new FacadeLogger(dispatcher);
}

internal static void SeparateBinLogArguments(IEnumerable<string>? args, out List<string> binLogArgs, out List<string> nonBinLogArgs)
Copy link
Preview

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding XML documentation comments for the SeparateBinLogArguments method to explain its behavior, especially the treatment of null inputs and the criteria used to separate binlog arguments.

Copilot uses AI. Check for mistakes.

@RikkiGibson RikkiGibson self-assigned this May 16, 2025
@jjonescz jjonescz requested a review from RikkiGibson June 9, 2025 11:51
nonBinLogArgs = new List<string>();
foreach (var arg in args ?? [])
{
if (IsBinLogArgument(arg))
Copy link
Member

Choose a reason for hiding this comment

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

This will return true for -bl which causes the switch -bl to be put into binLogArgs but not the value. Is that intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, -bl doesn't have a value, that would have to be written as -bl:value.

@jaredpar jaredpar added this to the 10.0.1xx milestone Jun 9, 2025
@jjonescz jjonescz requested a review from jaredpar June 9, 2025 15:44
@jjonescz jjonescz merged commit 74a28f7 into dotnet:main Jun 10, 2025
32 checks passed
@jjonescz jjonescz deleted the sprint-bl branch June 10, 2025 13:42
@jjonescz
Copy link
Member Author

oh, I forgot to get a review from CLI folks - @MiYanni if you have any feedback, please let me know and I can address in a follow up

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