As very well described by Sean Kearney at this great post, there are two ways to setup a Sitecore solution on Visual Studio for development:
1) Your solution, and code, is fully immersed in the Sitecore web site;
2) Your solution, and code, is outside of Sitecore’s web site and you use some post build process to deploy.
His post supports second option, which indeed has advantages over the first, however a huge drawback (specially for those without SSD) makes our life harder: due to the post build deployment, IIS is constantly forced to restart on every build you make.
In order to handle that issue I’ve invested some time looking for a better way to deploy. What if I copy only the modified changes instead of everything? Perhaps I could often skip the files that causes restarts, such as DLLs and config files…
My solution lied on robocopy, for advanced file copying. At your website project on Visual Studio, put this command at the Post-build event command line box:
robocopy “$(ProjectDir).” “C:\inetpub\wwwroot\YourProject\Website” /E /FFT /XO
- /E – Copies subdirectories;
- /XO – Excludes older files – this is the trick, skipping old files;
- /FFT – Assumes FAT file times (two-second precision) – this somehow interferes on how robocopy defines what is “older” to be copied;
- exit 0 – If we don’t add this to the end of the script, our Continuos Integration server breaks because robocopy returns a code different than “0” as success.
In my experience, even when you re-compile the solution without changing anything at the code, your IIS will not restart.