Ability to automatically remove files/folders no longer in build from deployment target

Is there a way to have Octopus automatically remove any files/folders that no longer exist in a package from the deployment target? I know you can purge the directory first, but this is not the option we want to use. Instead, say a folder named “Test” with some files under it is currently deployed, but a newer build removes that, we would like to have it also removed from the target when the deployment happens. I’m sure there has to be a way to do this and I hope the collective wisdom here can point me in the right direction.


Hi Justin,

Thanks for getting in touch! Unfortunately, there is no way in Octopus to do what you are after here. This is one of our thought processes behind not making Custom Installation Directory a default enabled feature. The default method that Octopus uses to manage its directories covers this by creating a new directory for every deployment. This also enables you to redeploy a previous version quickly if there is an issue with the newest release.

The only ideas that come to mind are as follows. The first being to purge the directory, but as you say that’s not an option. I believe creating a custom post-deploy script would be the only way that you could manage this.

Sorry for the bad news.

Best regards,