From cd357cb273a635c5087bc8e32ca4c7bcf07c7085 Mon Sep 17 00:00:00 2001 From: Sridhar Periyasamy Date: Fri, 4 Dec 2015 16:26:07 -0800 Subject: [PATCH] Fix dotnet driver on windows to deal with spaces dotnet driver fails running dotnet-restore.cmd if this file is in a path containing spaces. Use the magic "/S" switch in cmd to fix this. --- src/Microsoft.DotNet.Cli.Utils/Command.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.DotNet.Cli.Utils/Command.cs b/src/Microsoft.DotNet.Cli.Utils/Command.cs index ff88e3184..cfd979c73 100644 --- a/src/Microsoft.DotNet.Cli.Utils/Command.cs +++ b/src/Microsoft.DotNet.Cli.Utils/Command.cs @@ -88,14 +88,8 @@ namespace Microsoft.DotNet.Cli.Utils if (useCmd) { var comSpec = Environment.GetEnvironmentVariable("ComSpec"); - - // cmd doesn't like "foo.exe ", so we need to ensure that if - // args is empty, we just run "foo.exe" - if (!string.IsNullOrEmpty(args)) - { - executable = (executable + " " + args).Replace("\"", "\\\""); - } - args = $"/C \"{executable}\""; + // wrap 'executable' within quotes to deal woth space in its path. + args = $"/S /C \"\"{executable}\" {args}\""; executable = comSpec; }