Question

I have written this code after reading the link: http://blogs.technet.com/b/alexshev/archive/2008/03/25/property-does-not-exist-or-empty-when-accessed-from-deferred-custom-action.aspx

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Module Id="MergeModule1" Language="1033" Version="1.0.0.0">
    <Package Id="cffa568e-1bf0-4eb3-bee3-eb5801a0bbd0" Manufacturer="Microsoft" InstallerVersion="200" />

    <Binary Id="myCustomActionsDLL" SourceFile="CustomAction1.CA.dll" />

    <CustomAction Id="SetProperty" Execute="immediate" 
                  Property="CA_myCustomAction"
                  Value="InstallDir=[PRIMARYFOLDER];SourceDir=[SourceDir]" />


    <CustomAction
    Id="CA_myCustomAction"
    BinaryKey="myCustomActionsDLL"
    DllEntry="CustomAction1"
    Execute="deferred" Impersonate="no"
    Return="check" />

    <InstallExecuteSequence>
      <Custom Action="SetProperty" Before="InstallInitialize">Not Installed</Custom>
      <Custom Action="CA_myCustomAction" Before="InstallFinalize">Not Installed</Custom>
    </InstallExecuteSequence>

    <!--<InstallUISequence>
      <Custom Action="CA_myCustomAction" After="CostFinalize"></Custom>
    </InstallUISequence>-->

  </Module>
</Wix>

In place of InstallDir - PRIMARYFOLDER, I have tried - INSTALLLOCATION, InstallDir, TargetDir but I am unable to get the installation folder specified for the application which is under ProgramFiles(x86).

The value of the SourceDir is coming out as proper value where the MSI file is located while it is running.

Was it helpful?

Solution

Your troubleshooting should always start with generating and reading a verbose log. There are probably several problems all at once and all need to be fixed at the same time.

First is that your Type 51 set property custom action is scheduled before InstallInitialize. The property is not a secure custom property so it doesn't get passed into the transaction. Try scheduling it after InstallInitialize instead.

Second is you are in a merge module and merge modules modularize (append GUID) pretty much all identifiers. If you look at the build merge module in ORCA you'll see it's not looking for INSTALLDIR it's looking for INSTALLDIR.GUID.

If you really must use INSTALLDIR you want to define a property called INSTALLDIR with no value and use the SuppressModularization attribute to prevent the GUID. The approach I usually take though is to define a MergeRedirectFolder directory and use that instead. Then when I add the merge module to InstallShield I associate the module to INSTALLDIR and the transitive nature then takes over.

There may be other problems but it's hard to see without looking at the final MSI and reading through the logs.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Module Id="MergeModule2" Language="1033" Version="1.0.0.0">
    <Package Id="c4acbfbc-a0e8-4d52-b516-bee471a76e8a" Manufacturer="" InstallerVersion="200" />
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="MergeRedirectFolder"/>
    </Directory>
    <Binary Id="myCustomActionsDLL" SourceFile="CustomAction1.CA.dll" />
    <CustomAction Id="SetProperty" Execute="immediate"
                  Property="CA_myCustomAction"
                  Value="InstallDir=[MergeRedirectFolder];SourceDir=[SourceDir]" />
    <CustomAction Id="CA_myCustomAction"
        BinaryKey="myCustomActionsDLL"
        DllEntry="CustomAction1"
        Execute="deferred" Impersonate="no"
        Return="check" />
    <InstallExecuteSequence>
      <Custom Action="SetProperty" After="InstallInitialize">Not Installed</Custom>
      <Custom Action="CA_myCustomAction" Before="InstallFinalize">Not Installed</Custom>
    </InstallExecuteSequence>

  </Module>
</Wix>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top