一、不使用merge module的ModuleSubstitution和ModuleConfiguration
1.创建MyMsm.msm
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Module Id="MyMergeModule" Language="1033" Version="1.0.0.0">
<Package Id="dc9818b3-eee7-4c77-a2ba-fd742af8ab00" Manufacturer="Silly" InstallerVersion="200" /> <Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="INSTALLDIR" />
</Directory> <Component Guid="{B848E5EB-7985-4970-9D37-079A5C426808}" Directory="INSTALLDIR">
<File Id="_test.txt_4F7C5800031B" Source="test.txt" KeyPath="yes" />
</Component> </Module>
</Wix>
2.创建msi
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="b58a9d8b-479c-41c7-9de2-e635ce8a07a6" Name="MyMsi" Language="1033" Version="1.0.0.0" Manufacturer="Silly" UpgradeCode="c55a86e3-a7ac-491b-99b2-668771be11d4">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="INSTALLDIR">
<Merge Id="MyMsm.msm" SourceFile="MyMsm.msm" Language="1033" DiskId="1" />
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="MyMsi" Level="1">
<MergeRef Id="MyMsm.msm"/>
</Feature>
</Product>
</Wix>
二、使用merge module的ModuleSubstitution和ModuleConfiguration
1.创建MyMsm.msm
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Module Id="MyMergeModule" Language="1033" Version="1.0.0.0">
<Package Id="dc9818b3-eee7-4c77-a2ba-fd742af8ab00" Manufacturer="Silly" InstallerVersion="200" /> <Configuration Name="DIR_RETARGET_Silly" Format="Key" Type="Directory" DefaultValue="Silly" NonNullable="yes"/>
<Substitution Table="Directory" Row="INSTALLDIR" Column="Directory_Parent" Value="[=DIR_RETARGET_Silly]"/> <Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="INSTALLDIR" />
</Directory> <Component Guid="{B848E5EB-7985-4970-9D37-079A5C426808}" Directory="INSTALLDIR">
<File Id="FIL_test.txt_4F7C5800031B" Source="test.txt" KeyPath="yes" />
</Component> </Module>
</Wix>
2.创建MyMsi.msi
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="b58a9d8b-479c-41c7-9de2-e635ce8a07a6" Name="MyMsi" Language="1033" Version="1.0.0.0" Manufacturer="Silly" UpgradeCode="c55a86e3-a7ac-491b-99b2-668771be11d4">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="Silly" />
<Directory Id="INSTALLDIR">
<Merge Id="MyMsm.msm" SourceFile="MyMsm.msm" Language="1033" DiskId="1" >
<ConfigurationData Name="DIR_RETARGET_Silly" Value="Silly"/>
</Merge>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="WixProject1" Level="1">
<MergeRef Id="MyMsm.msm"/>
</Feature>
</Product>
</Wix>