Unable to fetch the install location property in a deferred custom action

你离开我真会死。 提交于 2019-12-11 19:25:59

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/17988392/unable-to-fetch-the-install-location-property-in-a-deferred-custom-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!