Redeploying an ASP.NET site in IIS7 without files in use interfering

Posted by fyjham on Stack Overflow See other posts from Stack Overflow or by fyjham
Published on 2010-03-12T06:37:55Z Indexed on 2010/03/12 6:47 UTC
Read the original article Hit count: 220

Filed under:
|
|
|

Hey,

We've got a process currently which causes ASP.NET websites to be redeployed. The code is itself an ASP.NET application. The current method, which has worked for quite a while, is simply to loop over all the files in one folder and copy them over the top of the files in the webroot.

The problem that's arisen is that occasionally files end up being in use and hence can't be copied over. This has in the past been intermittent to the point it didn't matter but on some of our higher traffic sites it happens the majority of the time now.

I'm wondering if anyone has a workaround or alternative approach to this that I haven't thought of. Currently my ideas are:

  1. Simply retry each file until it works. That's going to cause errors for a short time though which isn't really that good.
  2. Deploy to a new folder and update IIS's webroot to the new folder. I'm not sure how to do this short of running the application as an administrator and running batch files, which is very untidy.

Does anyone know what the best way to do this is, or if it's possible to do #2 without running the publishing application as a user who has admin access (Willing to grant it special privileges, but I'd prefer to stop short of administrator)?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET