Fix argument passing in GlobalToolShim (#21333)

This commit is contained in:
Friedrich von Never
2024-03-26 13:58:57 -07:00
committed by GitHub
parent 6253933501
commit ff3c847898
@@ -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;
}