From e61de6b1cc58baa3e1d5e33c18383fa401057f19 Mon Sep 17 00:00:00 2001 From: Chris Savoie Date: Thu, 31 Oct 2019 19:59:47 -0700 Subject: [PATCH] [Custom Build Steps] Fixes to get custom build steps working. * Add quotes to executable if it's a single line string that doesn't already have quotes. * Standardize the path when looking up the build step since it may be lower cased. --- Sharpmake.Generators/VisualStudio/Vcxproj.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Sharpmake.Generators/VisualStudio/Vcxproj.cs b/Sharpmake.Generators/VisualStudio/Vcxproj.cs index 4c1cce30b..35c142cad 100644 --- a/Sharpmake.Generators/VisualStudio/Vcxproj.cs +++ b/Sharpmake.Generators/VisualStudio/Vcxproj.cs @@ -178,11 +178,17 @@ public static Dictionary CombineCustomFileB foreach (var customBuildStep in buildSteps) { var relativeBuildStep = customBuildStep.MakePathRelative(resolver, (path, commandRelative) => Util.SimplifyPath(Util.PathGetRelative(referencePath, path))); - relativeBuildStep.AdditionalInputs.Add(relativeBuildStep.Executable); + var executable = relativeBuildStep.Executable; + if (!executable.StartsWith("\"") && !executable.EndsWith("\"") && !executable.Contains("\n")) + { + executable = string.Format("\"{0}\"", executable); + } + + relativeBuildStep.AdditionalInputs.Add(executable); // Build the command. string command = string.Format( "{0} {1}", - relativeBuildStep.Executable, + executable, relativeBuildStep.ExecutableArguments ); @@ -1430,10 +1436,12 @@ IList skipFiles { fileGenerator.Write(Template.Project.ProjectFilesCustomBuildBegin); + var standardPath = Util.PathMakeStandard(file.FileNameProjectRelative); + foreach (Project.Configuration conf in context.ProjectConfigurations) { CombinedCustomFileBuildStep buildStep; - if (configurationCustomFileBuildSteps[conf].TryGetValue(file.FileNameProjectRelative, out buildStep)) + if (configurationCustomFileBuildSteps[conf].TryGetValue(standardPath, out buildStep)) { using (fileGenerator.Declare("conf", conf)) using (fileGenerator.Declare("platformName", Util.GetPlatformString(conf.Platform, conf.Project, conf.Target)))