Exclude certain files from default Purge Option


I want to exclude certain files like App_Offline.htm in the default Purge option, is that possible?

Manasa Bhavanari

Hi Manasa,

Thanks for getting in touch! The purge option is complete and does not have the option to exclude files. Your only real option would be to add a deploy script yourself to purge the directory and exclude the files. We have a documentation page that explains the ordering of our package steps and when scripts and events are run: https://octopus.com/docs/reference/package-deployment-feature-ordering


never thought it is that much easy with Octopus. it worked great.

here is the sample i used.

Write-Host “Executed after the package is extracted”
$projectName = $OctopusParameters[‘Octopus.Project.Name’]
Write-Host “Project: $projectName”
$installationFolder = $OctopusParameters[‘Octopus.Action.Package.CustomInstallationDirectory’]
Write-Host “Installation Folder: $installationFolder”

Write-Host "Purging the previous Deployment except app_offline.htm"
Write-Host "Executing: Remove-Item $installationFolder* -recurse -exclude app_offline.htm "
Remove-Item $installationFolder* -recurse -exclude app_offline.htm
Write-Host “Purging is complete”

Write-Host "start sleeping"
Write-Host "Executing: Start-Sleep -m 15000"
Start-Sleep -m 15000
Write-Host “sleeping complete”

Hey Manasa

where do add this deploy scripts.

With Hearty Radhasoami


For your Deployment step, you need to “Configure Features” then select “Custom Deployment Scripts”, after that you will see option to add Pre Deploy, Deploy and Post Deploy scripts.

You can refer this: https://octopus.com/docs/deploying-applications/custom-scripts#Customscripts-Scriptsinpackagesteps


Hi Manasa,

Glad to hear you got this working so quickly.

If you have any other issues or questions do not hesitate to reach out.

Thank you Manasa!


  • Kapil

It looks like there is now an exclude option attached to purge on the custom installation directory feature.


That is more handy now. Thank you for the update, i really appreciate it.