Fix argument passing in GlobalToolShim (#21333)

This commit is contained in:
Friedrich von Never 2024-03-27 03:58:57 +07:00 committed by GitHub
parent 6253933501
commit ff3c847898
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;
}