Currently PowerShellLocator seems not working as expected.
It's always resolved to Windows PowerShell and pwsh seems not be used.
Problems
1. Wrong subdirectories are selected
https://github.com/dotnet/BenchmarkDotNet/blob/605cd1f3ed8e22def7ef1b8adfc6f7f4937f0051/src/BenchmarkDotNet/Helpers/PowerShellLocator.cs#L36C100-L41
Currently, all subdirectories are listed up (e.g. 7\zh-Hant) and regex seems not working as expected.
Because regex is using partial match. and testing with full path.
It needs following changes.
- Use
SearchOption.TopDirectoryOnly
- Use
Regex.IsMatch(Path.GetFileName(x), "^[0-9]+$") to filter by directory name.
2. -Command argument is required to run command with pwsh
When using pwsh to execute command. It need to specify -Command argument explicitly.
3. ANSI escape sequence is added when running command with pwsh
It need to use | Out-String to suppress ANSI escape sequence.
|
$"Get-CimInstance Win32_Processor -Property {argList} | Format-List {argList}"); |
Currently PowerShellLocator seems not working as expected.
It's always resolved to
Windows PowerShellandpwshseems not be used.Problems
1. Wrong subdirectories are selected
https://github.com/dotnet/BenchmarkDotNet/blob/605cd1f3ed8e22def7ef1b8adfc6f7f4937f0051/src/BenchmarkDotNet/Helpers/PowerShellLocator.cs#L36C100-L41
Currently, all subdirectories are listed up (e.g.
7\zh-Hant) and regex seems not working as expected.Because regex is using partial match. and testing with full path.
It needs following changes.
SearchOption.TopDirectoryOnlyRegex.IsMatch(Path.GetFileName(x), "^[0-9]+$")to filter by directory name.2.
-Commandargument is required to run command with pwshWhen using
pwshto execute command. It need to specify-Commandargument explicitly.3. ANSI escape sequence is added when running command with pwsh
It need to use
| Out-Stringto suppress ANSI escape sequence.BenchmarkDotNet/src/BenchmarkDotNet/Detectors/Cpu/Windows/PowershellWmiCpuDetector.cs
Line 27 in 605cd1f