ubisoft / Sharpmake

Sharpmake is an open-source C#-based solution for generating project definition files, such as Visual Studio projects and solutions, GNU makefiles, Xcode projects, etc.
Apache License 2.0
945 stars 171 forks source link

[MSBuild] CustomBuildStep executable fails if the path contains spaces #214

Closed mundak closed 2 years ago

mundak commented 2 years ago

Here's example sharpmake.cs configuration:

      conf.CustomFileBuildSteps.Add(new Configuration.CustomFileBuildStep
      {
        KeyInput = @"[project.SourceRootPath]\build_dll_pch.h",
        Output = @"[project.RootDirectory]\out\build_dll_pch.pch",
        Description = "Generating precompiled header for tests...",
        Executable = @"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\x64\bin\clang++.exe",
        ExecutableArguments
        = @"-std=c++20 -O3 -x c++-header [input] -I[project.RootDirectory]\src -o [output]"

When Visual Studio projects are generated, the path is not escaped, therefore the command fails with: program C:\Program cannot be found.

I suggest a fix in the Vcxproj.cs file:

image

(wrapping {0} with ")

If that fix looks correct to you, I'm happy to fill a PR. Otherwise, maybe I'm doing something wrong?

jspelletier commented 2 years ago

looks fine to me. I guess we don't notice this internally as we are using nuget based toolchain packages and they have no spaces in paths.