0

In a .NET Core project, I want to copy some dll's after the project has compiled. I have successfully done that with a simple xcopy operation setup in the scripts -> postcompile section of the project.json file.

I want this copy-operation to be cross-platform, so xcopy is not an option (for Mac/Linux at least). Is there a way to copy the files that works cross platform, or some way to detect the platform so I can branch out and call a cmd script when on Windows and a shell script when on Mac/Linux?

Henrik Nielsen
  • 410
  • 2
  • 6

1 Answers1

0

Assuming you are using the project.json build system, this can be done by referencing a script file without the file extension in the "scripts" section.

"scripts": {
  "postcompile": "copy-assets"
}

To support cross-plat, you need two script files in the same folder as project.json, copy-assets.cmd and copy-assets.sh. Make sure to chmod +x your .sh file to it can be executed.

natemcmaster
  • 25,673
  • 6
  • 78
  • 100
  • Would the above postcompile value which is "copy-assets" (without the extension sh or cmd) automatically pick up "copy-assets.sh" on a mac and pick "copy-assets.cmd" on a windows? – whyAto8 May 23 '19 at 07:25