diff --git a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleProcessManager.cs b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleProcessManager.cs index abeb12e72b..3934f37c50 100644 --- a/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleProcessManager.cs +++ b/src/Microsoft.TestPlatform.VsTestConsole.TranslationLayer/VsTestConsoleProcessManager.cs @@ -150,7 +150,7 @@ public void StartProcess(ConsoleParameters consoleParameters) public void ShutdownProcess() { // Ideally process should die by itself - if(!processExitedEvent.WaitOne(ENDSESSIONTIMEOUT) && IsProcessInitialized()) + if (!processExitedEvent.WaitOne(ENDSESSIONTIMEOUT) && IsProcessInitialized()) { EqtTrace.Info($"VsTestConsoleProcessManager.ShutDownProcess : Terminating vstest.console process after waiting for {ENDSESSIONTIMEOUT} milliseconds."); vstestConsoleExited = true; @@ -220,15 +220,16 @@ private string[] BuildArguments(ConsoleParameters parameters) if (isNetCoreRunner) { - args.Insert(0, vstestConsolePath); + args.Insert(0, GetEscapeSequencedPath(vstestConsolePath)); } return args.ToArray(); } private string GetConsoleRunner() - { - return isNetCoreRunner ? ( string.IsNullOrEmpty(this.dotnetExePath) ? new DotnetHostHelper().GetDotnetPath() : this.dotnetExePath) : vstestConsolePath; - } + => isNetCoreRunner ? (string.IsNullOrEmpty(this.dotnetExePath) ? new DotnetHostHelper().GetDotnetPath() : this.dotnetExePath) : GetEscapeSequencedPath(this.vstestConsolePath); + + private string GetEscapeSequencedPath(string path) + => string.IsNullOrEmpty(path) ? path : $"\"{path.Trim('"')}\""; } } \ No newline at end of file