Skip to content

Commit

Permalink
Fix argument passing in GlobalToolShim (#21333)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Mar 26, 2024
1 parent 6253933 commit ff3c847
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public static int Main(string[] args)

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))
{
Expand All @@ -41,7 +42,7 @@ public static int Main(string[] args)
e.Cancel = true;
};

var process = System.Diagnostics.Process.Start("dotnet", processArgs);
var process = System.Diagnostics.Process.Start("dotnet", arguments);
process.WaitForExit();
return process.ExitCode;
}
Expand Down

0 comments on commit ff3c847

Please sign in to comment.