0

I'm looking for a way to add an extra build step which will create a backup copy of my entire solution. I want it to do this only if a file in the solution, or the entire solution itself, is not present in the destination folder or flashdrive directory. What would be the easiest way to achieve this? Preferably I would only want this to happen if a file is deemed "newer", and avoid the copy and replace if the file has not changed since the last backup.

Krythic
  • 3,334
  • 5
  • 20
  • 59

1 Answers1

1

You can do this with a batch file using

xcopy /D

which will copy only those files whose source time is newer than the destination time. Or robocopy.

This could recursively copy the entire directory, particular folders, or particular file types. If you're willing to launch your builds from the batch file itself (rather than within visual studio) the batch file has everything you need. Otherwise you might find Solution-wide pre-build event? useful for setting this up to work through Visual Studio. If you follow that process you should be able to take advantage of the Visual Studio Macros for Build Commands like $(SolutionPath).

If you need only those files actually contained in your projects then parsing the solution and project files may be necessary. The .NET framework provides some libraries to help parse solution or project files (SolutionParser). See Parsing Visual Studio Solution files

That would be a bit of work, but you build a list of only those files contained in your projects and use with xcopy or robocopy.

Community
  • 1
  • 1
jhh
  • 613
  • 4
  • 6