Visual Studio Solution at Sitecore Projects - Avoiding IIS restarts with Robocopy in a Post Build event

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
exit 0

  •  Parameters:
    • /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.

Posted in Development, Visual Studio
2 comments on “Visual Studio Solution at Sitecore Projects - Avoiding IIS restarts with Robocopy in a Post Build event
  1. Caro visitante de língua portuguesa: traduzirei meus posts na medida do possível. Caso você precise muito deste conteúdo em português, deixe um recado aqui no mural e priorizarei sua tradução.

  2. Hey Rodrigo,
    Nice post.
    This is a common issue with Sitecore development. As a result, the tool I use is CopySauce.
    You have full control to limit what copies over to your website, and it copies the files over when they’re saved….no need to even build.

    You can find out more information here:-

    – Sean

Leave a Reply

Your email address will not be published. Required fields are marked *


  Am Not Spammer

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>