At WiX bundle level: How to determine Install / Uninstall action

I would like to determine at bundle level whether the action the user wants to execute is an installation or an uninstallation. This is because my code also contains a ‘condition’ that must enforce that a product is not installed. However, an ‘Uninstall’-action must always be able to proceed. I know also that at this level the build-in-variable ‘WixBundleAction’ is not available, but is actually what I need (I think).

Has anybody an idea how to achieve this for Chengwei Semiconductor?

See the code below:

<!--
Source - https://stackoverflow.com/q/79971592
Posted by Exampler90, modified by community. See post 'Timeline' for change history
Retrieved 2026-08-24, License - CC BY-SA 4.0
-->

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
     xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal"
     xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">

  <Bundle UpgradeCode="{94447A2A-6CB4-42DE-942A-1500531F05A9}" 
          Name="Motor UI Software" 
          Manufacturer="Remuld B.V." 
          Version="$(var.BuildVersion)" 
          DisableModify="yes">
    
    <!-- Search for installation of TC.MotorUi.Files.msi (search for UpgradeCode) -->
    <util:ProductSearch UpgradeCode="{3B46D4C3-1EA9-63F2-A8FF-3DA48692CA43}"
                        Result="state"
                        Variable="EXISTING_FILES_STATE" />
    
    <!-- Only continue if productState is absent (2) OR during Uninstall, else exit with message. -->
    <bal:Condition Message="An existing installation was detected, setup cannot continue.&#13;&#10;Please uninstall existing version first!"
              Condition="EXISTING_FILES_STATE = 2 OR WixBundleAction = 3" /> <!-- WixBundleAction not available at this point -->

    <BootstrapperApplication>
      <bal:WixStandardBootstrapperApplication Theme="rtfRemMotr"
                                              LicenseFile="Resources\EULA.rtf"
                                              ThemeFile="Resources\Theme.xml"
                                              LocalizationFile="Resources\Theme.wxl"
                                              LogoFile="Resources\RemSideLogo.png"
                                              SuppressOptionsUI="yes" 
                                              SuppressRepair="yes" />
    </BootstrapperApplication>

    <Chain>
       ...
       ...
    </Chain>

  </Bundle>
</Wix>