If you’ve ever tried to copy the source files from a Visual Studio 2005 ASP.NET solution, especially if you’re using TFS and Resharper, you’ll have probably noticed all great steaming heaps of fluff and nonsense these tools leave all over your hard drive. Not to mention all the built assemblies lurking in your bin/Debug folders.
Prepare a file with the inclusion / exclusion rules for the files / folders you want to copy. For my solution, it looks like this:
There are a few fascinating points to note about this file:
- The lines that begin with a ‘+’ character are include rules.
- The second line copies anything in a /lib folder, which is where we keep dependencies in my world
- The second-to-last line tells rsync to copy every folder. Without this, the last line would exclude all the folders (rsync works its way through the folder tree recursively) and you’d never get to the files you’d mentioned above. Read that bit again, it’s hard to understand at first, but important.
- The last line excludes everything else.
Now fire up your terminal, and invoke the magic of rsync:
rsync -av –exclude-from=files.txt source/Projects/Widgets/ target/Projects/Widgets/
- copy all files (recursively)
- write verbose output
And there you have it. Yet more unix joy.