From 1d39e2288cfd4be267c07e89e352a31803f6ce3b Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Wed, 28 Aug 2019 17:00:08 -0700 Subject: [PATCH 1/3] Allow all arguments to be sent to Powershell global tool --- src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs b/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs index 5f51e0644d5..ae93170fbe4 100644 --- a/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs +++ b/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs @@ -31,7 +31,7 @@ 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)) { From 24e377c1ec73a8c83e7221302cad36045343bfad Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 29 Aug 2019 11:39:24 -0700 Subject: [PATCH 2/3] Add quotes around pwsh full path and return exit code --- .../GlobalToolShim.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs b/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs index ae93170fbe4..53a823beb50 100644 --- a/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs +++ b/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs @@ -22,7 +22,7 @@ public class EntryPoint /// Entry point for the global tool. /// /// Arguments passed to the global tool. - public static void Main(string[] args) + public static int Main(string[] args) { var currentPath = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).Directory.FullName; var isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); @@ -31,11 +31,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} {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 { From f137d15d4d3ba0789e881bef0a74eac69d8a1109 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 29 Aug 2019 11:51:41 -0700 Subject: [PATCH 3/3] Fix codefactor issue --- src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs b/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs index 53a823beb50..79c13b4efc5 100644 --- a/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs +++ b/src/Microsoft.PowerShell.GlobalTool.Shim/GlobalToolShim.cs @@ -21,7 +21,8 @@ public class EntryPoint /// /// Entry point for the global tool. /// - /// Arguments passed to the global tool. + /// Arguments passed to the global tool.' + /// Exit code returned by pwsh. public static int Main(string[] args) { var currentPath = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).Directory.FullName;