Skip to content

Conversation

@jjonescz
Copy link
Member

@jjonescz jjonescz commented Aug 13, 2025

Fixes the inconsistency described in #50227 (comment).

@jjonescz jjonescz added the Area-run-file Items related to the "dotnet run <file>" effort label Aug 13, 2025
@jjonescz jjonescz marked this pull request as ready for review August 13, 2025 14:48
@jjonescz jjonescz requested review from a team and Copilot August 13, 2025 14:48
Copy link
Contributor

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 consolidates the default verbosity setting for MSBuild-based commands to ensure consistent behavior across the dotnet CLI. The change addresses issue #50227 by centralizing the default verbosity configuration.

  • Introduces a centralized DefaultVerbosity constant set to VerbosityOptions.m
  • Updates VirtualProjectBuildingCommand to use the centralized default instead of hardcoded quiet verbosity
  • Adds comprehensive tests to verify verbosity behavior for run, build, and compilation diagnostic scenarios

Reviewed Changes

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

File Description
src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildForwardingAppWithoutLogging.cs Defines centralized DefaultVerbosity constant and updates class to be sealed
src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs Updates to use centralized default verbosity instead of hardcoded quiet
src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildArgs.cs Minor cleanup removing unused using statement and empty XML doc return tag
test/dotnet.Tests/CommandTests/Run/RunFileTests.cs Adds tests for verbosity behavior in run, build, and compilation diagnostic scenarios

@jjonescz
Copy link
Member Author

@RikkiGibson @333fred for reviews, thanks

private readonly List<string> _msbuildRequiredParameters = [ "-maxcpucount", "--verbosity:m" ];
private readonly List<string> _msbuildRequiredParameters = ["-maxcpucount", $"--verbosity:{DefaultVerbosity}"];

internal const VerbosityOptions DefaultVerbosity = VerbosityOptions.m;
Copy link
Member

Choose a reason for hiding this comment

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

nit: It might be good to put this const with the other consts above. In particular seeing it used in an initializer just before its definition causes me to do a double take, until I realize it is a const it feels like something may be wrong.

.WithWorkingDirectory(testInstance.Path)
.Execute()
.Should().Pass()
// no additional build messages
Copy link
Member

Choose a reason for hiding this comment

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

It feels like if no build message is expected then it would be good to verify that, for example, the stdout does not contain Program.dll.

Copy link
Member Author

Choose a reason for hiding this comment

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

HaveStdOut verifies the stdout is exactly as written (nothing more), plus there is NotHaveStdErr to check stderr as well, but I can add .And.NotHaveStdOutContaining("Program.dll") to be even more specific.

@jjonescz jjonescz enabled auto-merge (squash) August 20, 2025 08:29
@jjonescz jjonescz merged commit 078ccf5 into dotnet:main Aug 20, 2025
27 checks passed
@jjonescz jjonescz deleted the sprint-build-output branch August 20, 2025 14:19
@jjonescz
Copy link
Member Author

/backport to release/10.0.1xx

@github-actions
Copy link
Contributor

Started backporting to release/10.0.1xx: https://github.com/dotnet/sdk/actions/runs/17297895713

@github-actions
Copy link
Contributor

@jjonescz backporting to "release/10.0.1xx" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Consolidate default verbosity of msbuild-based commands
Using index info to reconstruct a base tree...
M	src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildArgs.cs
M	src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs
M	test/dotnet.Tests/CommandTests/Run/RunFileTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Cli/Microsoft.DotNet.Cli.Utils/MSBuildArgs.cs
Auto-merging src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs
Auto-merging test/dotnet.Tests/CommandTests/Run/RunFileTests.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Consolidate default verbosity of msbuild-based commands
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

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