sponte / Powershell.Deployment

Powershell scripts that automated component deployment. Supports windows services (srvany.exe, NServiceBus, TopShelf) and websites.
MIT License
15 stars 8 forks source link

Prevent failure when multiple install or uninstall are executed against IIS #36

Closed RavindraSolanki closed 6 years ago

RavindraSolanki commented 6 years ago

This pull-request mitigate the following issue. When installing or uninstalling a site or a web app, IIS locks the 'applicationHost.config' file while it is writing in it. If multiple sites or web apps or appPools are being created or removed at the same time the operation might fail and an exception is returned.

This PR adds a retry mechanism as suggested in this thread. The Operation is tried a maximum of 5 times with a random wait time between each retry.

This PR adds some cosmetic changes:

RavindraSolanki commented 6 years ago

I've made some changes to look the best of the two worlds.

For all the IIS actions run through Powershell.Deployments a mutex is used to synchronise the execution. However, I'm conscious something might happen outside Powershell.Deployment and a retry-mechanism is in place for this eventuality.