Depending on your Web Server set up, you might not be able to overwrite the Bin folder without some manually intervention. Usually it is because there is a process using files within the Bin folder and you will have to stop the application pool first.
Octopus will soon inform you if this is the case when deploying your package to the server, and will give you the error message:
One or more files in the directory may be locked by another process. You could use a PreDeploy.ps1 script to stop any processes that may be locking the file. Error details follow.
There is a pretty easy solution for this. You can run some Custom PowerShell scripts during Pre/Post deployment.
To set up the Pre/Post deployment scripts within the deployment of a NuGet package step, select the step and click on Configure features. This will then give you the option to Enable Custom PowerShell scripts.
This will then give you the option to enter pre-deployment, deployment and post-deployment scripts. You will want to enter the Stop PowerShell script in the pre box.
And then the Start PowerShell script in the post box.
In both scripts, you will notice
appPoolName, this is a Variable which you will need to set up with the name of the application pool named
In your next release you will see two additional steps in the Task Log. If you see these and everything is green then you know everything is ok!
Many thanks to @ahandersson for helping me out over in the Octopus Jabbr room