-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Read dotnet.config file to use MTP or VSTest in dotnet test #46717
Read dotnet.config file to use MTP or VSTest in dotnet test #46717
Conversation
Was there a decision to call the INI file |
The file name and format are still under discussion but as we need to move forward to allow internal dogfooding it was decided to temporarly move on with that (cc @baronfel ) |
private static string? GetDotnetConfigPath(string? startDir) | ||
{ | ||
string? directory = startDir; | ||
while (directory != null) | ||
{ | ||
string dotnetConfigPath = Path.Combine(directory, "dotnet.config"); | ||
if (File.Exists(dotnetConfigPath)) | ||
{ | ||
return dotnetConfigPath; | ||
} | ||
|
||
directory = Path.GetDirectoryName(directory); | ||
} | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose such a restriction is not necessary for security because the volume root directory on Windows typically has an NT AUTHORITY\Authenticated Users:(AD)
access control entry. This ACE allows the user to create a subdirectory such as .config
in the root directory, and the user can then get full control on the new subdirectory and create a dotnet-tools.json
file in there. However, the ACE does not allow the user to create a file such as dotnet.config
or global.json
directly in the root directory. See FILE_ADD_SUBDIRECTORY in File Access Rights Constants.
This pull request includes significant changes to the
TestCommandParser
class in thedotnet-test
command. The primary focus of these changes is to improve the configuration handling and test runner determination logic.Configuration handling improvements:
src/Cli/dotnet/commands/dotnet-test/TestCommandParser.cs
: AddedMicrosoft.Extensions.Configuration
to handle configuration files.src/Cli/dotnet/commands/dotnet-test/TestCommandParser.cs
: Introduced theGetTestRunnerName
method to determine the test runner based on thedotnet.config
file.Test runner determination logic:
src/Cli/dotnet/commands/dotnet-test/TestCommandParser.cs
: Replaced theIsTestingPlatformEnabled
method withGetTestRunnerName
to dynamically determine the test runner name from the configuration file.src/Cli/dotnet/commands/dotnet-test/TestCommandParser.cs
: Updated theConstructCommand
method to use the newGetTestRunnerName
method for selecting the appropriate CLI command.src/Cli/dotnet/commands/dotnet-test/TestCommandParser.cs
: Added theGetDotnetConfigPath
helper method to locate thedotnet.config
file starting from the current directory.Relates to #45927