Clean destination leaves empty sub folders

The “Delete all existing files before copying” option seems to delete files from sub folders in the destination path, but then leaves the empty sub folders behind instead of removing them too. Is this by design? Is there an option to clean the destination recursively (including sub folders)?

Hi,

There isn’t currently; you could do this in your PreDeploy.ps1 as a workaround for the time being. We’ll try to do this in Octopus 2.0.

Paul

Appreciate the feedback. Thanks!

work-around (for my case using C:\Octopus\Deployed")

Use this as PreDeploy.ps1
function Get-Tree($Path,$Include=’’)
{
@(Get-Item $Path -Include $Include) + (Get-ChildItem $Path -Recurse -Include $Include) |
sort pspath -Descending -unique
}
function Remove-Tree($Path,$Include=’
’)
{
Get-Tree $Path $Include | Where-Object {$_.name -ne ‘deployed’ } | Remove-Item -force -recurse
}

Remove-Tree ‘c:\octopus\deployed’