0
votes

I am new to Wix. I am using version 3.9 to run a custom action. I am able to copy over files and install and uninstall, but I am trying to get a custom action to run with no luck at all.

Below is a small example, the ComponentGroup is in another file that is created by heat. I run the installer with logging and see nothing in the log file about the action failing on install, when I run uninstall I see a cmd prompt open.

I am also confused on Wix conditions and how they are evaluated. From various sources this is what I see for a condition and it

  • MyProperty returns true if property has been set to any value including 0 or false
  • NOT MyProperty returns true is property has not been set

When used in a condition this says that if MyProperty is false, NOT MyProperty will return false. And, if MyProperty is true, in a condition MyProperty will return false. This confuses me and the custom action firing during uninstall confuses me.

Any help would be appreciated.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" >
  <Product Id="*" Name="GtLite" Language="1033" Version="1.0.0.0" Manufacturer="Acme" UpgradeCode="0cd4e6db-ec32-42b4-bcb8-1f51f37c7b44">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <!-- Specify minimal UI -->
    <UIRef Id="WixUI_Minimal" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate EmbedCab="yes" />

    <!-- Features to install -->
    <Feature Id="ProductFeature" Title="FunTimes" Level="1">

      <ComponentGroupRef Id="BinFilesGroup" />
    </Feature>

    <CustomAction Id="RunDataUtility"
                  Directory="FUN_FOLDER" ExeCommand="cmd.exe /k &quot;echo hello > [FUN_FOLDER]echo_test.txt&quot;" Execute="immediate" Return='asyncNoWait' />


    <InstallExecuteSequence>

      <Custom Action="RunDataUtility" After="InstallFiles" >NOT INSTALLED</Custom>
    </InstallExecuteSequence>


    <Directory Id="TARGETDIR" Name="SourceDir">

      <!-- Define Installation folder under Program Data -->

      <Directory Id="ProgramFolder">
        <Directory Id="INSTALL_FOLDER" Name="Acme" >
          <Directory Id="FUN_FOLDER" Name="FunTimes" >
          </Directory>
        </Directory>
      </Directory>
    </Directory>

  </Product>

</Wix>
1
Where is your echo test text file coming from? If you are installing it your custom action needs to be deferred because immediate custom actions run before any files are installed.PhilDW
The echo to a file called echo_test.txt was a test to see the custom action run. I changed the custom After tag to InstallFinalize, but left execute as immediate and now my real custom action is running from the install folder. Also changed BIN_FOLDER to FUN_FOLDER. I am still very new to wix and working on my understanding of it.dgxhubbard

1 Answers

1
votes

Are you passing BIN_FOLDER via the commandline? I ask because I am not able to see that being set here. Though I have not tested this command, but I am guessing this should work. Please give it a try and let me know.

<CustomAction Id="ConfigureApp_Cmd" Property="ConfigureApp" Execute="immediate"
    Value="&quot;cmd.exe /k&quot; &quot;echo hello > [BIN_FOLDER]echo_test.txt&quot; nopause;" />
<CustomAction Id="ConfigureApp" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="asyncNoWait" Impersonate="no"/>

<InstallExecuteSequence>
    <Custom Action="ConfigureApp_Cmd" After="StartServices"><![CDATA[NOT(Installed)]]></Custom>
    <Custom Action="ConfigureApp" After="ConfigureApp_Cmd"><![CDATA[NOT(Installed)]]></Custom>
</InstallExecuteSequence>

You might have to pass something similar to BIN_FOLDER=C:\Acme\bin to make this work.