autostart website after web deploy

2019-09-05 06:00发布

问题:

I have a IIS website with multiple application connected to the same app pool and I deploy regularly some of those website through web deploy with the msdeploy tool. One of this app is set to autostart with the serviceAutoStartEnabled="true" and a matching serviceAutoStartProvider.

It works well when I restart the whole app pool but the autostart is not triggered when I web deploy the website

Is there any way to tell IIS to "restart" fully the website after the deploy and not wait for the first request to it ?

回答1:

You could use a post sync command:

msdeploy -verb:sync -preSync:runCommand="net stop w3svc" -source:webserver60 -dest:auto,computername=serverA -verbose -postSync:runCommand="appcmd start site /site.name: contoso" 

https://technet.microsoft.com/en-us/library/ee619740(v=ws.10).aspx