Post build events using ROBOCOPY instead of XCOPY
Posted
by
Vizioz Limited
on Vizioz Umbraco Blog
See other posts from Vizioz Umbraco Blog
or by Vizioz Limited
Published on 2010-03-18T16:55:00.001-07:00
Indexed on
2010/12/06
17:00 UTC
Read the original article
Hit count: 650
Build Process
|Umbraco Development
For the last few months we have been building a website framework for a client, who has subsequently sold the site to 5 clients, each with a different skin and some variations in their functional requirements.
So, we now have a single source solutions, that builds and copies the site files into 5 seperate local websites, which enables us to easily test them all, what we had found was that this process was starting to slow up our build process and was reaching 30-45 seconds on a high spec Quad core machine (and slower on others)
Today I asked Colin to create seperate Solution Configurations within Visual Studio so that while we were developing we could target a single site, and when we wanted to test all sites, we could target "ALL" and the Post Build script would then copy the files to all sites.
This worked well, and with a couple of other optimisations, our build was now taking about 10 seconds for a single site.
Then Colin came across ROBOCOPY and suggested that maybe this would be a suitable alternative to XCOPY, well, I had not heard of it.. (shock horror some of you shout, some I am sure like me, are also wondering what it is!)
ROBOCOPY is new in Windows Vista & Windows 7 (you can also download it for XP & Windows 2003) and it has a lot of additional features, the two that were most interesting to us were:
/MIR = Mirror a folder tree
/XD = Exclude Directories
/NP = No Progress (i.e. it does not give you a chart of it's results, which just fills up your Output window!)
So, we set about implementing ROBOCOPY, we decided to use the /MIR switch on all folders that we knew were always stored in our project folders:
- images
- css
- masterpages
- xslt
And for other files we just used the straight robocopy functionality.
We also decided to exclude all the .SVN directories using the /XD switch and finally we added the /NP switch as mentioned above.
The beauty of all of this, is the /MIR functionality, as this means that only files that have changed will be copied across which greatly speeds up the process, especially on the images folders which previously copied across on every build, now, if we add a new image to the project it will be copied across automatically and then never again, unless we change it of course!
The build time now for all sites is approximately 4 seconds and for a single site, 2 seconds, I would highly recommend the time to make the same optimisations to your build processes if you have not done so already.
© Vizioz Umbraco Blog or respective owner