Unnecessary Files while deploying

Hello,
I am experimenting CI/CD with teamcity and octopus. I manage to deploy project successfully and everything was fine in development environment. But when it comes to production environment, my company needs to remove all those unnecessary files from deployed location. So, I figured out there are few ways from teamcity server side and few ways from octopus server side such as Deployment Scripts. But I am not sure is there any easy way to do this? So can anyone please walk me through here.

So this what folder looks like after deploying with Visual Studio Publish

And Here what it looks like after octopus deploy

Is there any possible way to make my deployment target make look like picture 01 without writing post deploy scripts to remove folders one by one? It doesn’t matter whether solution applies to octopus server or teamcity.

If my question is unclear please let me know. I am expecting most efficient way to remove all those unnecessary files. Any kind of reply would be massive help for me.

Thank you for taking time to read this. Have a nice day!
-Chamod-

Hey @chamodshelan,

Thanks for reaching out.

Looking at the extra files, it looks like your source files are in there. It looks like the output directory from the build might need to be adjusted, then set that directory when you use octo pack and all of the extra stuff should be gone when deploying with Octopus.

Would you be able to take a look at your build process and see if the output directory might be causing the issue? Feel free to share settings/commands and I can take a look with you.

Please let me know what you think.

Thanks,
Jeremy

Hi @jeremy.miller
hank you replying,
Actually I am not using octo pack because I am not familiar with octo pack. Instead of octo pack I use following build step to push package to octopus server.


My build step in main sever also looks something similar to this. Here I cannot exclude files. I use pre-deploy ps script remove files like web.config. But I think doing same thing here will not be much efficient. If you can refer me to a correct path that would be great. I am open to any suggestion.

Thank you again
-Chamod-

Hi @chamodshelan,

You’re very welcome.

I think what you will need to do is before this step is set the output folder for your build step to be outside of the project source folder. It all looks like your project files are in the same folder as your completed build in the NorthwindSolution directory. Are you able to choose a different output directory, then in the step you screenshotted choose that directory to make the zip?

So like this
NorthwindSolution has your Source files for your build
During the build, output to maybe NorthwindSolution/outputfiles
Then during the push step, have it reference NorthwindSolution/outputfiles

If you can’t do that, you could do a script step before this to move the files you want to a folder and use that folder to create the zip.

Please let me know if that makes sense.

Thanks,
Jeremy

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.