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



我需要从合并模块将一些文件安装到Public Documents。我正在尝试使用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不能在合并模块中工作?

原因

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

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

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

解决方案

抑制WIX_DIR_COMMON_DOCUMENTS的模块化,如下所示:

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

在构建使用合并模块的安装程序时,如果该安装程序已经引用了WixUtilExtension中的WIX_DIR_COMMON_DOCUMENTS或其他目录,则可能会收到一些警告。可以安全地忽略这些。

E。g.在我的实验中,我得到了以下警告:

C:UsersREDACTEDsourcereposSetupProject1SetupProject1Product.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:UsersREDACTEDsourcereposSetupProject1MergeModule1binDebugMergeModule1.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:UsersREDACTEDsourcereposSetupProject1SetupProject1Product.wxs(38,0): warning LGHT1055: The InstallUISequence table contains an action 'WixQueryOsDirs' which cannot be merged from the merge module 'C:UsersREDACTEDsourcereposSetupProject1MergeModule1binDebugMergeModule1.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:UsersREDACTEDsourcereposSetupProject1SetupProject1Product.wxs(38,0): warning LGHT1055: The InstallExecuteSequence table contains an action 'WixQueryOsDirs' which cannot be merged from the merge module 'C:UsersREDACTEDsourcereposSetupProject1MergeModule1binDebugMergeModule1.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:UsersREDACTEDsourcereposSetupProject1SetupProject1Product.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:UsersREDACTEDsourcereposSetupProject1MergeModule1binDebugMergeModule1.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:UsersREDACTEDsourcereposSetupProject1SetupProject1Product.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:UsersREDACTEDsourcereposSetupProject1MergeModule1binDebugMergeModule1.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

最新更新