diff --git a/GVFS/GVFS.Common/FileSystem/HooksInstaller.cs b/GVFS/GVFS.Common/FileSystem/HooksInstaller.cs index 8480f83a0..76fc6d028 100644 --- a/GVFS/GVFS.Common/FileSystem/HooksInstaller.cs +++ b/GVFS/GVFS.Common/FileSystem/HooksInstaller.cs @@ -28,7 +28,8 @@ static HooksInstaller() public static string MergeHooksData(string[] defaultHooksLines, string filename, string hookName) { IEnumerable valuableHooksLines = defaultHooksLines.Where(line => !string.IsNullOrEmpty(line.Trim())); - string absolutePathToHooksExecutable = Path.Combine(ExecutingDirectory, GVFSPlatform.Instance.Constants.GVFSHooksExecutableName); + /* Wrap in quotes to handle spaces in the path */ + string absolutePathToHooksExecutable = $"\"{Path.Combine(ExecutingDirectory, GVFSPlatform.Instance.Constants.GVFSHooksExecutableName)}\""; if (valuableHooksLines.Contains(GVFSPlatform.Instance.Constants.GVFSHooksExecutableName, GVFSPlatform.Instance.Constants.PathComparer)) { diff --git a/GVFS/GVFS.UnitTests/CommandLine/HooksInstallerTests.cs b/GVFS/GVFS.UnitTests/CommandLine/HooksInstallerTests.cs index bf40c040b..a9a5fcbf9 100644 --- a/GVFS/GVFS.UnitTests/CommandLine/HooksInstallerTests.cs +++ b/GVFS/GVFS.UnitTests/CommandLine/HooksInstallerTests.cs @@ -16,9 +16,7 @@ public class HooksInstallerTests { private const string Filename = "hooksfile"; private readonly string expectedAbsoluteGvfsHookPath = - Path.Combine( - Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), - GVFSPlatform.Instance.Constants.GVFSHooksExecutableName); + $"\"{Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), GVFSPlatform.Instance.Constants.GVFSHooksExecutableName)}\""; [TestCase] [Category(CategoryConstants.ExceptionExpected)]