Cleaning folder based on nuspec

Hi guys

we are having some special cases out of control, which hope you guys can help.

here is the case:

In nuspecs:
Country A:
Country B:

In Octopus:
Both projects for country A and B use same variable(D:\Resources) in Custom install directory.

we cant tick “Purge this directory before installation” because if we do so, the whole Resources will be purged., which means either of these two projects got deployed, all the folders for other countries will be removed.

what we want is when we deploying Country A, it will clean the AAAImages folder and put new stuff in, or if AAAImage folder can be deleted before deploymend would also good for us. i reckon if we can find a variable in octopus which has the value as D:\Resources\AAAImage, then the problem is solved.

hope it makes sense for you guys.


Hi Ben,

Thank you for reaching out! It appears that you are on the correct track, and have an idea how to resolve this issue. I have made a couple of assumptions and interpretations of the problem so please correct me if I am wrong.

To specify the folder you want to purge, first create variables that each has the purge directory specific to each project (such as PurgeDirectory with a value of AAAImage for project A). Then using our PreDeploy.ps1 convention you can create a script that will use that variable and purge it for you. As you cannot define a different purge directory directly in the feature itself. That will mean the script is executed near the beginning of your package step, so later it will then re-populate your images folder. See our package deployment feature ordering:

Let me know how you go!

Kind regards,