Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public class EntryPoint
/// <summary>
/// Entry point for the global tool.
/// </summary>
/// <param name="args">Arguments passed to the global tool.</param>
public static void Main(string[] args)
/// <param name="args">Arguments passed to the global tool.</param>'
/// <returns>Exit code returned by pwsh.</returns>
public static int Main(string[] args)
{
var currentPath = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).Directory.FullName;
var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
Expand All @@ -31,11 +32,13 @@ public static void Main(string[] args)

string argsString = args.Length > 0 ? string.Join(" ", args) : null;
var pwshPath = Path.Combine(currentPath, platformFolder, PwshDllName);
string processArgs = string.IsNullOrEmpty(argsString) ? $"{pwshPath}" : $"{pwshPath} -c {argsString}";
string processArgs = string.IsNullOrEmpty(argsString) ? $"\"{pwshPath}\"" : $"\"{pwshPath}\" {argsString}";

if (File.Exists(pwshPath))
{
System.Diagnostics.Process.Start("dotnet", processArgs).WaitForExit();
var process = System.Diagnostics.Process.Start("dotnet", processArgs);
process.WaitForExit();
return process.ExitCode;
}
else
{
Expand Down