Search code examples
c#visual-studioprojectsolutionxcopy

Adding pre-build commands to copy files to a project in VS 2017


I have a folder which has a bunch of scripts in it. These are NOT in a project or solution.

What I need to do is using the pre-build event in VS, is copy these files using xcopy into the debug folder of a project.

I have worked out how to do this with stuff inside a solution or project. But trying to do it with external files is eluding me

Can anybody point me in the right direction please?


Solution

  • Projects have a Pre-build event that can be used for doing what you are looking to do.

    You can find this in the Project Properties in the Build Events section. Try the command as per:

    c:\windows\system32\xcopy D:\source\*.* "$(TargetDir)" /s /e
    

    For a list of the Build Parameters see MSDN: https://msdn.microsoft.com/en-us/library/42x5kfw4.aspx

    The quotes around the $(TargetDir) are important if you have a space in any of your folder/file names