Skip to content

Conversation

mariam-abdulla
Copy link
Member

@mariam-abdulla mariam-abdulla commented Aug 22, 2025

This pull request refactors how the dotnet test CLI command handles directory inputs, removing the --directory option and improving project/solution file resolution logic. The changes simplify the user experience by allowing directories to be passed to --project or --solution and enhance ambiguity handling when multiple project files are present. Validation and error messaging have also been updated to reflect these improvements.

Command-line interface and options:

  • Removed the --directory option from the CLI, parser, and options definitions, so directories should now be specified using --project or --solution. [1] [2] [3]
  • Updated resource strings and translations to reflect the new guidance for specifying directories. [1] [2] [3]

Project and solution resolution logic:

  • Refactored MSBuildHandler to distinguish between directory and file inputs for project/solution options, using new helper methods to resolve the correct file when a directory is given. [1] [2]
  • Added TryGetProjectFilePath and TryGetSolutionFilePath methods in SolutionAndProjectUtility to handle directories and resolve ambiguities when multiple project files are present. [1] [2]

Validation improvements:

  • Updated validation logic to handle directories passed to --project/--solution and provide more accurate error messages. [1] [2]
  • Removed validation and references for the deprecated --directory option. [1] [2]

General code cleanup:

  • Removed unused using statements and simplified some type references for clarity and consistency. [1] [2] [3] [4]

Fixes #50325

@mariam-abdulla mariam-abdulla requested a review from a team as a code owner August 22, 2025 13:06
@@ -115,42 +115,40 @@ public void RunWithInvalidProjectExtension_ShouldReturnExitCodeGenericFailure(st

[InlineData(TestingConstants.Debug)]
[InlineData(TestingConstants.Release)]
[Theory]
public void RunWithInvalidSolutionExtension_ShouldReturnExitCodeGenericFailure(string configuration)
[PlatformSpecificTheory(TestPlatforms.Any & ~TestPlatforms.OSX)]
Copy link
Member

Choose a reason for hiding this comment

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

Why is this not working on macOS?

@mariam-abdulla mariam-abdulla merged commit dc4b5fa into release/10.0.1xx Aug 25, 2025
26 of 27 checks passed
@mariam-abdulla mariam-abdulla deleted the dev/mabdullah/remove-directory-option-in-dotnet-test branch August 25, 2025 13:43
@Youssef1313 Youssef1313 linked an issue Aug 27, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revise --project, --solution, and --directory of dotnet test
2 participants