Sharpmake icon indicating copy to clipboard operation
Sharpmake copied to clipboard

Support IsFileCopy and IsRecurse in BuildStepCopy under MSBuild for parity with FASTBuild

Open doanamo opened this issue 3 years ago • 0 comments
trafficstars

  • Use xcopy instead of robocopy for copying single file when IsFileCopy is true
  • Specify proper flag for robocopy when IsRecurse is true

Example cases that this change fixes under MSBuild, which work as expected with FASTBuild.

  1. On MSBuild only top level directory will be copied without subdirectories, despite IsRecurse being set to true by default.
// directory copy
conf.EventPostBuildExe.Add(new Configuration.BuildStepCopy(
    sourcePath: "[project.SourceRootPath]\\directory",
    destinationPath: "[conf.TargetPath]\\directory",
    fileCopy: false
));
  1. On MSBuild file will not be copied at all. Workaround for compatibility with FASTBuild was to specify only source/destination directories and copy pattern with specific filename.
// single file copy
conf.EventPostBuildExe.Add(new Configuration.BuildStepCopy(
    sourcePath: "[project.SourceRootPath]\\executable.exe",
    destinationPath: "[conf.TargetPath]\\executable.exe",
    fileCopy: true
));

Please note that this change will affect projects that depend on BuildStepCopy not doing recursive copy under MSBuild - these projects will now have to explicitly set IsRecurse to false.

doanamo avatar Jul 20 '22 18:07 doanamo