You can execute a custom action or make the component install using conditions as per the requirement.
- Condition for Action to run only during Installation
Condition: NOT Installed - Condition for Action to run only during Uninstallation/Removal of MSI
Condition: REMOVE="ALL" - Condition for Action to run during Install and repair
Condition: NOT REMOVE - Condition for Action to run only during Upgrade
Condition: NOT UPGRADINGPRODUCTCODE