locked
Is it neccassary to recycle the app pool when placing a WCF project to live? RRS feed

  • Question

  • I can't seem to figure out how I can do this inside my work flow. My boss seems to think it is important and would like our script to do this. We are running IIS 7... Any suggestions?
    Tuesday, August 17, 2010 2:53 PM

Answers

  • Hi,

    To use appcmd on another PC, you have to use PowerShell

     

    1 Save following script as D:\RecycleAppPool.ps1

       invoke-command -computername <RemoteServer>  -scriptblock {\Windows\system32\inetsrv\appcmd recycle apppool <AppPoolName>}

       To make sure this command work, you can logon as TFSBuild account open Powershell on Build Server to run above script. You may have to run Set-ExecutionPolicy RemoteSigned  to enable PS accept script files.

    2 In InvokeProcess Activity, excute PowerShell.exe with arguments -file D:\RecycleAppPool.ps1

    You can also try to run this command in commandline to make sure that this command could run.

    I test abovesteps in Windows Server 2008 R2, if there is any question regarding PowerShell, you can visit PowerShell forum and there will be more members that could help you.


    Best regards,
    Ruiz
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com
    • Marked as answer by bccollin Monday, August 30, 2010 5:58 PM
    Thursday, August 19, 2010 6:46 AM
    Moderator

All replies

  • We are using WebDeploy to put our things to work. I think this might be a good idea to look at.

    The drawback is that is uses an IIS as template for the deploy, and you need to be an admin (at least until IIS Express comes alive) to be able to do these things.

    Using Lab Management and the build agents that comes with that might be another thing to look at. The advantage there is that you can run things on different machines with ease.

    Pretty much depends on what you actually wants to be done...

    If you provide some more information I might be able to help you more...


    Tomas Scott
    Tuesday, August 17, 2010 3:01 PM
  • Basically I have a workflow that does a number of things like building, versioning, replacing web config values, deploying the database, moving the files to the live virtual directory etc... After files are copied to the live virtual directory I would like to recycle the application pool on that machine. Getting into Lab Management and multiple build agents is far beyond the scope of this. I'd like to be able to write up a quick and dirty code activity if possible.
    Tuesday, August 17, 2010 3:06 PM
  • OK, so the AppPool is on the same machine?
    Guess you could just kick off a command script that recycles the app pool then.

    See the following info
    http://gallery.technet.microsoft.com/ScriptCenter/en-us/22b10d93-e734-4fda-8ebe-2df30e54c64b
    or

    http://technet.microsoft.com/en-us/library/cc770764(WS.10).aspx

    Hope this helps!

     


    Tomas Scott
    Tuesday, August 17, 2010 3:19 PM
  • Thanks for the help but no it won't be on the same machine. The workflow will be running off our source control server and is deploying to our application server via a share.
    Tuesday, August 17, 2010 3:29 PM
  • So I am not sure how to remote execute a script - I know Lab Mgmt can do this, but I guess there are other techniques as well to just remote-execute a command.
    For example http://gallery.technet.microsoft.com/ScriptCenter/en-us/32368e16-d678-48aa-a0a1-c2f51e16aff2

     


    Tomas Scott
    Tuesday, August 17, 2010 4:20 PM
  • I am not familiar with this language... is it not possible to do something through C#? I've found examples about how to do this with IIS6 but they do not work for IIS7.

     

    Here's an example: 

    using( DirectoryEntry applicationPool = new

                DirectoryEntry( "IIS://localhost/W3SVC/AppPools/" + "DefaultAppPool" ) ) {

                applicationPool.Invoke( "Recycle" );

             }

    Tuesday, August 17, 2010 4:53 PM
  • It is just a simple VBScript. But today PowerShell would be the best choice...

     


    Tomas Scott
    Tuesday, August 17, 2010 4:55 PM
  • Hi bccollin,

    You can use Appcmd.exe to recycle the app pool.


    C:\Windows\System32\inetsrv>appcmd recycle apppool <App Pool Name>

    http://technet.microsoft.com/en-us/library/cc770764(WS.10).aspx

    http://technet.microsoft.com/en-us/library/cc772200(WS.10).aspx

     Add a InvokeProcess Activity in your build work flow. Make sure that TFSBuild asscount has right to manage IIS.


    Best regards,
    Ruiz
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com
    Wednesday, August 18, 2010 8:02 AM
    Moderator
  • How do I point appcmd to another PC?
    Wednesday, August 18, 2010 3:42 PM
  • Hi,

    To use appcmd on another PC, you have to use PowerShell

     

    1 Save following script as D:\RecycleAppPool.ps1

       invoke-command -computername <RemoteServer>  -scriptblock {\Windows\system32\inetsrv\appcmd recycle apppool <AppPoolName>}

       To make sure this command work, you can logon as TFSBuild account open Powershell on Build Server to run above script. You may have to run Set-ExecutionPolicy RemoteSigned  to enable PS accept script files.

    2 In InvokeProcess Activity, excute PowerShell.exe with arguments -file D:\RecycleAppPool.ps1

    You can also try to run this command in commandline to make sure that this command could run.

    I test abovesteps in Windows Server 2008 R2, if there is any question regarding PowerShell, you can visit PowerShell forum and there will be more members that could help you.


    Best regards,
    Ruiz
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com
    • Marked as answer by bccollin Monday, August 30, 2010 5:58 PM
    Thursday, August 19, 2010 6:46 AM
    Moderator