Fix argument passing in GlobalToolShim (#21333) (#23912)

This commit is contained in:
Aditya Patwardhan
2024-06-11 10:07:13 -07:00
committed by GitHub
parent 3ce794d1e4
commit f7dc7be700
@@ -30,9 +30,10 @@ namespace Microsoft.PowerShell.GlobalTool.Shim
string platformFolder = isWindows ? WinFolderName : UnixFolderName;
string argsString = args.Length > 0 ? string.Join(" ", args) : null;
var arguments = new List<string>(args.Length + 1);
var pwshPath = Path.Combine(currentPath, platformFolder, PwshDllName);
string processArgs = string.IsNullOrEmpty(argsString) ? $"\"{pwshPath}\"" : $"\"{pwshPath}\" {argsString}";
arguments.Add(pwshPath);
arguments.AddRange(args);
if (File.Exists(pwshPath))
{
@@ -41,7 +42,7 @@ namespace Microsoft.PowerShell.GlobalTool.Shim
e.Cancel = true;
};
var process = System.Diagnostics.Process.Start("dotnet", processArgs);
var process = System.Diagnostics.Process.Start("dotnet", arguments);
process.WaitForExit();
return process.ExitCode;
}