I am trying to deploy a .NET Web application to IIS (7.5) without any hassle for the users. I have made sure that Disable Overlapped Recycle is False b
Whilst Smirkin's answer provides a nice seamless way for an Admin to deploy a site with little or no downtime, and should resolve your issue with missing assemblies/references, if you have breaking changes in your code-base (i.e. removing old pages, changes to forms, etc.), then using this method could still result in some "hassle" for any users who start a process before the switch and complete it after the switch (i.e., they request a page before you switch over, start filling it in, and then submit the page after you've switched over to the new directory).
I know you don't want me to say this, but without a load-balancer with Sticky-Sessions enabled, you won't be able to allow people to continue using the old version of the site until they've finished while handling new sessions on the new version - by changing the home directory of the application, IIS will perform a re-compile of the app and restart the processes. This way you can set the old server to continue serving its current connections, but tell the load-balance not to send any new connections to it.
There is however another step you can take to help mitigate the issues often seen around this:
Configure the MachineKey to be a constant value rather than AutoGenerate
- this means that when the AppPool recycles it will use the same key, and so be able to decrypt session cookies, viewstate, etc.
you could use app_offline.htm
this solution is not seamless, but you could use a
<meta http-equiv="refresh" content="5" />
in the htm file, so the browser automatically refreshes the without any javascript.
cheers
I agree with Smirkin's response - updating a second folder and changing the IIS home directory to point to the other folder. Another advantage to this is that you have an easy rollback path (just switch the IIS home directory back).
I've written a post with a script on how to do this using Powershell - hope it helps: http://davidduffett.net/post/4833657659/blue-green-deployment-to-iis-with-powershell
You should be able to use this script directly from your continuous integration system.
When deploying ASP.Net applications I create a new folder on the server and change the home directory of the website within IIS. This provides zero downtime deployment and a quick rollback position in case of unforeseen issues. On a future update I scrap the old version and repeat the process so that there is always a single rollback position.
Details configuring the shutdown time limit for workers is detailed at http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/add/processModel. The default is 1 min 30 secs. Look for the shutdownTimeLimit section in the linked page.
Similar question with a great answer
The gist of this is that the due to overwritting the existing files the copying mechanism takes an exclusive lock on the files and that it is not possible to have seemless deployment without use of app_offline.htm or a mechanism such as suggested above. Take a read of the linked answer as it goes into much more depth.
My guess is that you have a virus scanner or some other kind of indexing process that it locking the file as soon as you copy it out there.