the way MSI infrastructure works is first deploy the files and then do the rest, so if u wish to run some cleanup before even extracting the Msi package, u have few alternatives:
1. extract the files to a backup folder other this the desired installation directory, then perform your cleanup and then copy the binaries to the real installation directory.
2. have a nested msi installers, the outer installer (container) package will contain the actual installer plus an executable/script which will be run by the container installer.
the executable/script will first wait till the container msi finish the installation (since 2 MSI instances cannot run on the same time), then run the cleanup, then install the inner MSI package and finally uninstall the Msi
container.
option #2 sounds complicated and i actually implemented this in my company to support pre/post installation procedures to have the ability to run scripts before installation and after installation (and they can't be part of the Msi package itself).