My project has an “uploads” style folder, where content is supposed to remain on-disk and in the same folder between deployments.
Octopus creates a new directory for each deployment, but that means this folder is lost between deployments.
Is there a way to keep this folder with future deployments? What is the best practice?
There are two options I can think of:
OctopusPackageDirectoryPath to deploy the package to the same path every time. Tentacle won’t delete existing files in the folder, it will just overwrite the new files.
- Change the application to use a different folder configured through an app setting
For example, you might have this appSetting:
<add key="UploadsFolder" value="C:\Uploads" />
You can then use a HttpHandler to serve files out of that folder, or map it as a virtual directory in IIS separate to the main application.
What’s nice about option 2 is that you could later point this path to a file share (if you have multiple web servers needing the same uploads folder) without doing a rewrite, so in general I like this approach from an architectural point of view. But I understand if you don’t want to change the application just yet, which is why option 1 is available.
Hope that helps,
Was just looking for a solution for the same situation and came across this. However, I also need the ability to delete everything else b/c otherwise my MVC app may not behave correctly.
I realize this question is old, so is there now a way to use OctopusPackageDirectoryPath, but have OD delete everything except one or more specified paths? Or maybe a newer alternative?
Thanks for reaching out. This is indeed a Really old thread.
What you could do is add enable the feature Custom Deployment Scripts and add a Pre-Deployment Script that deletes the files you dont wanna overwrite from the working folder. That way, when Octopus finally copies the files from the working directory to the target directory, it won’t overwrite the files you want to keep.
Hope that helps,