【问题标题】:Unable to fetch the install location property in a deferred custom action无法在延迟的自定义操作中获取安装位置属性
【发布时间】:2013-08-01 08:06:08
【问题描述】:

我在阅读链接后编写了这段代码: 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>

代替InstallDir - PRIMARYFOLDER,我已经尝试过 - INSTALLLOCATION、InstallDir、TargetDir,但我无法获取为 ProgramFiles(x86) 下的应用程序指定的安装文件夹。

SourceDir 的值是 MSI 文件在运行时所在位置的正确值。

【问题讨论】:

    标签: .net wix installshield setup-deployment merge-module


    【解决方案1】:

    您的故障排除应始终从生成和阅读详细日志开始。可能同时存在多个问题,需要同时解决。

    首先,您的 Type 51 设置属性自定义操作已安排在 InstallInitialize 之前。该属性不是安全的自定义属性,因此不会传递到事务中。请尝试在 InstallInitialize 之后安排它。

    其次是你在一个合并模块中,合并模块模块化(附加 GUID)几乎所有的标识符。如果您查看 ORCA 中的构建合并模块,您会发现它不是在寻找 INSTALLDIR,而是在寻找 INSTALLDIR.GUID。

    如果您确实必须使用 INSTALLDIR,您需要定义一个没有值的名为 INSTALLDIR 的属性,并使用 SuppressModularization 属性来阻止 GUID。我通常采用的方法是定义一个 MergeRedirectFolder 目录并改用它。然后,当我将合并模块添加到 InstallShield 时,我将模块与 INSTALLDIR 相关联,然后传递性质接管。

    可能还有其他问题,但如果不查看最终的 MSI 并阅读日志,很难发现。

    <?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>
    

    【讨论】:

    • 非常感谢!似乎除了你之外,stackoverflow 上没有人知道 wix。您能否在互联网上为我提供一个使用 MergeRedirectFolder 或 SuppressModularization 的示例或指针?
    • 使用 MergeRedirectFolder 更新了示例。我无法在这里展示的部分是,当您将合并模块添加到 InstallShield 时,您必须右键单击它并使用下拉列表将合并模块与 INSTALLDIR 关联。
    • 谢谢,我会在星期一试试这个。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-29
    相关资源
    最近更新 更多