Hey I would love to know what you think while reading my posts. Please comment!.

Stopping and Starting your Application Pool with Octopus Deploy

Depending on your Web Server set up, you might not be able to overwrite the Bin folder without some manually intervention. Usually it is because there is a process using files within the Bin folder and you will have to stop the application pool first.

Octopus will soon inform you if this is the case when deploying your package to the server, and will give you the error message:

One or more files in the directory may be locked by another process. You could use a PreDeploy.ps1 script to stop any processes that may be locking the file. Error details follow.

There is a pretty easy solution for this. You can run some Custom PowerShell scripts during Pre/Post deployment.

To set up the Pre/Post deployment scripts within the deployment of a NuGet package step, select the step and click on Configure features. This will then give you the option to Enable Custom PowerShell scripts.

Export Layers to files options

This will then give you the option to enter pre-deployment, deployment and post-deployment scripts. You will want to enter the Stop PowerShell script in the pre box.

Export Layers to files options

And then the Start PowerShell script in the post box.

Export Layers to files options

In both scripts, you will notice appPoolName, this is a Variable which you will need to set up with the name of the application pool named AppPoolName.

In your next release you will see two additional steps in the Task Log. If you see these and everything is green then you know everything is ok!

Export Layers to files options Export Layers to files options

Job Done!

Many thanks to @ahandersson for helping me out over in the Octopus Jabbr room


About Me

Tim James I'm Tim, a web applications developer from Glasgow, Scotland. Currently working for Kingfisher Systems Ltd, building bespoke systems within the Car Auction industry.

  • C#
  • VB.NET
  • ASP.NET
  • .NET MVC
  • Web API
  • Razor
  • HTML5
  • CSS3
  • jQuery
  • WCF
  • SQL
  • knockout.js
  • Angularjs
  • AJAX
  • APIs
  • SignalR
Why not follow me on twitter? Follow me on Twitter