如何在合并模块中将文件安装到公共文档?

时间:2019-02-07 03:01:34

标签: wix merge-module wix3.11

我需要从我的合并模块中向公共文档安装一些文件。我正在尝试使用WIX_DIR_COMMON_DOCUMENTS属性,但是所有文件都安装到了程序文件中。

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

<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在合并模块中不起作用?

1 个答案:

答案 0 :(得分: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中的其他目录,则可能会收到一些警告。这些可以安全地忽略。

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

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

相关问题