Skip to content

Commit 81f9cce

Browse files
CopilotMalcolmnixon
andcommitted
Use COMSPEC environment variable for Windows shell path
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
1 parent 16fe7b7 commit 81f9cce

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/DemaConsulting.DotnetToolWrapper.Tests/IntegrationTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,14 @@ private static void CreateConfigFile(string program, string? directory = null)
9393
/// <returns>Shell program name</returns>
9494
private static string GetShellProgram()
9595
{
96-
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "cmd.exe" : "/bin/sh";
96+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
97+
{
98+
// Use COMSPEC environment variable to get full path to cmd.exe
99+
var comspec = Environment.GetEnvironmentVariable("COMSPEC");
100+
return comspec ?? throw new InvalidOperationException("COMSPEC environment variable not found");
101+
}
102+
103+
return "/bin/sh";
97104
}
98105

99106
/// <summary>

0 commit comments

Comments
 (0)