Welcome, Guest! Registration


Friday, 2019-02-22
Main » 2016 » July » 3 » Create custom install/uninstall actions on WiX wxs msi
3:09 PM
Create custom install/uninstall actions on WiX wxs msi

Here is how to create custom actions to be called at install and uninstall in WiX (msi). You may need to call your own scripts at install or uninstall to do some setup or cleanup. Here is wss example how to do it in the overall wxs structure:

<?xml version="1.0" encoding="utf-8"?>
<Wix ...>
  <Product ...>
    <Package ... />
    <Media ... />
    <SetDirectory ... />
    <Feature ...>
      <ComponentRef .../>
    <UI />
    <!-- Custom actions begin -->
    <Custom Action="MyActionInstallName" After="InstallFiles">(NOT Installed) AND (NOT REMOVE)</Custom>
    <Custom Action="MyActionUninstallName" Before="InstallFiles">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
    <CustomAction Id="MyActionInstallName" Return="check" Impersonate="no" Execute="deferred" Directory="TARGETDIR" ExeCommand="MyInstallCommand"/>
    <CustomAction Id="MyActionUninstallName" Return="check" Impersonate="no" Execute="deferred" Directory="TARGETDIR" ExeCommand="MyUninstallCommand"/>
    <!-- Custom actions end -->

The interesting part is between <!-- Custom actions begin --> and <!-- Custom actions end -->. In the install execute sequence's <Custom ...>, it is critical to use After="InstallFiles" attribute and (NOT Installed) AND (NOT REMOVE) condition; and in the uninistall sequence Before="InstallFiles" with (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") as these attributes are required for proper actions sequencing and conditions are required triggering. If you won't use these conditions, the actions will be executed both on install and uninstall. The rest can be tweakied to your liking, and you will probably have to change names of items starting with "My".


Views: 2643 | Added by: ep | Tags: Wix, install, MSI, MS Windows | Rating: 0.0/0
Total comments: 0
Only registered users can add comments.
[ Registration | Login ]