- enable new build system if you use Legacy Build System.
File -> Project Settings (or Workspace Settings) -> Build System -> Choose "New Build System(Default).
- skip script in build pharse by check checkbox "Run script only when installing" or
if [ $ENABLE_PREVIEWS == "NO" ]
then
# your code to execute here
else
echo "Skipping the script because of preview mode"
fi