1

我需要从我的合并模块将一些文件安装到公共文档。我正在尝试使用 WIX_DIR_COMMON_DOCUMENTS 属性,但所有文件都安装到 Program Files。

这是我的合并模块源代码:

<PropertyRef Id="WIX_DIR_COMMON_DOCUMENTS" />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="MergeRedirectFolder">
    <Directory Id="MirProgramFolder" Name="Data">
      <Component Id="cmpData" Guid="c64db3df-1bf3-4c03-8b69-ac1adbb8bfdd">
        <File Id="filData" Source="ForProgramFiles.txt"/>
      </Component>
    </Directory>
  </Directory>

  <!-- Files to install to public documents folder -->
  <Directory Id="WIX_DIR_COMMON_DOCUMENTS">
    <Directory Id="MirCommonDocumentsFolder" Name="MIR">
      <Component Id="cmpTest" Guid="22381726-2cf0-45f0-a9a8-9703ed456ed6">
        <File Id="filTest" Source="ForPublicDocs.txt"/>
      </Component>
    </Directory>
  </Directory>
</Directory>

这是我的安装项目源代码:

<Product Id="*" Name="SetupProject1" Language="1033" Version="1.0.0.0" Manufacturer="Slava Antonov" UpgradeCode="7418b1ee-fb1e-4000-995f-4cff646346c5">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

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

    <Feature Id="ProductFeature" Title="SetupProject1" Level="1">
  <MergeRef Id="MergeModule1"/>
    </Feature>
</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="SetupProject1" />
        </Directory>
    </Directory>
</Fragment>

<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
  <Merge Id="MergeModule1" SourceFile="$(var.MergeModule1.TargetDir)MergeModule1.msm" DiskId="1" Language="1033"/>
</DirectoryRef>
</Fragment>

为什么 WIX_DIR_COMMON_DOCUMENTS 在合并模块中不起作用?

4

1 回答 1

1

原因

当您<Directory Id="WIX_DIR_COMMON_DOCUMENTS">在合并模块源中写入时,WiX 会将目录 ID模块化,以防止与使用合并模块的产品中的任何现有目录 ID 发生冲突。

您可以通过在 Orca 或InstEd(推荐)中打开 MSM 文件并查看Directory表格来验证这一点。您将看到一个目录 ID,如WIX_DIR_COMMON_DOCUMENTS.9FE2C761_1860_4D8C_8538_352164BDC12F. 附加的 GUID 是合并模块 ID。

不幸的是,自定义操作WixQueryOsDirs仅设置属性WIX_DIR_COMMON_DOCUMENTS而不是使用模块化目录 ID,因此模块化目录 ID 仍将指向程序文件目录。

解决方案

像这样抑制模块化WIX_DIR_COMMON_DOCUMENTS

<PropertyRef Id="WIX_DIR_COMMON_DOCUMENTS"/>
<Property Id="WIX_DIR_COMMON_DOCUMENTS" SuppressModularization="yes"/>

在构建使用合并模块的设置时,当此设置已经引用WIX_DIR_COMMON_DOCUMENTS或来自 WixUtilExtension 的其他目录时,您可能会收到一些警告。这些可以安全地忽略。

例如。在我的实验中,我收到了以下警告:

C:\Users\REDACTED\source\repos\SetupProject1\SetupProject1\Product.wxs(38,0): warning LGHT1056: The Directory table contains a row with primary key(s) 'WIX_DIR_COMMON_DOCUMENTS' which cannot be merged from the merge module 'C:\Users\REDACTED\source\repos\SetupProject1\MergeModule1\bin\Debug\MergeModule1.msm'.  This is likely due to collision of rows with the same primary key(s) (but other different values in other columns) between the database and the merge module.
C:\Users\REDACTED\source\repos\SetupProject1\SetupProject1\Product.wxs(38,0): warning LGHT1055: The InstallUISequence table contains an action 'WixQueryOsDirs' which cannot be merged from the merge module 'C:\Users\REDACTED\source\repos\SetupProject1\MergeModule1\bin\Debug\MergeModule1.msm'.  This action is likely colliding with an action in the database that is being created.  The colliding action may have been authored in the database or merged in from another merge module.  If this is a standard action, it is likely colliding due to a difference in the condition for the action in the database and merge module.  If this is a custom action, it should only be declared in the database or one merge module.
C:\Users\REDACTED\source\repos\SetupProject1\SetupProject1\Product.wxs(38,0): warning LGHT1055: The InstallExecuteSequence table contains an action 'WixQueryOsDirs' which cannot be merged from the merge module 'C:\Users\REDACTED\source\repos\SetupProject1\MergeModule1\bin\Debug\MergeModule1.msm'.  This action is likely colliding with an action in the database that is being created.  The colliding action may have been authored in the database or merged in from another merge module.  If this is a standard action, it is likely colliding due to a difference in the condition for the action in the database and merge module.  If this is a custom action, it should only be declared in the database or one merge module.
C:\Users\REDACTED\source\repos\SetupProject1\SetupProject1\Product.wxs(38,0): warning LGHT1056: The CustomAction table contains a row with primary key(s) 'WixQueryOsDirs' which cannot be merged from the merge module 'C:\Users\REDACTED\source\repos\SetupProject1\MergeModule1\bin\Debug\MergeModule1.msm'.  This is likely due to collision of rows with the same primary key(s) (but other different values in other columns) between the database and the merge module.
C:\Users\REDACTED\source\repos\SetupProject1\SetupProject1\Product.wxs(38,0): warning LGHT1056: The Property table contains a row with primary key(s) 'SecureCustomProperties' which cannot be merged from the merge module 'C:\Users\REDACTED\source\repos\SetupProject1\MergeModule1\bin\Debug\MergeModule1.msm'.  This is likely due to collision of rows with the same primary key(s) (but other different values in other columns) between the database and the merge module.

所以 WiX 告诉我们它不能导入属性WIX_DIR_COMMON_DOCUMENTSSecureCustomProperties自定义操作WixQueryOsDirs,因为它们已经存在于主产品中。这没什么好担心的,因为合并模块的组件会愉快地使用现有的属性WIX_DIR_COMMON_DOCUMENTS

于 2019-02-09T10:36:01.343 回答