The Pre and Post-deploy scripts are designed to run on every release of the project. Your best practice is to make them repeatable. Add checks so that if the data already exists, you don't run again or something like that. You can create some kind of basic logging table to save this - if the row is not found in the table, run the script and put the row in the table.
You cannot tell the project to only run the latest version of the script if there are several scripts, because they are all embedded in one large file, PreDeploy.sql or PostDeploy.sql. You will need something in each / script section that tells it where to look, know or not to run. This may be an existing data check, a table check, a version check, or something else, but she must know somewhere what to use in order to know whether to run it.
It is impossible to disable this, except to comment on the scripts or process them in any way through the SQLCMD variables or other checks. However, you still need coding in how each script should be executed or not. If you give an example or two of what you are trying to accomplish in your Pre / Post Deploy scripts, we can probably give some recommendations.
For our purposes, we make scripts reusable and delete them as they run. They are still in the original management or you can use a snapshot to store this version of the project until they are deleted.
Peter Schott
source share