WiX - 在安装时设置合并模块目录?

Ayo*_*o I 3 wix merge-module wix3.5

我按照入门Wix指南中的说明创建了一个合并模块:http://wix.sourceforge.net/manual-wix2/authoring_merge_modules.htm .

这是合并模块wxs:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Module Id="SomeRepositoryMergeModule" Language="1033" Version="1.0.0.0">
    <Package Id="f11e7321-a687-4d53-8be7-21a8ae0721a6" Manufacturer="SomeCompany Technologies" InstallerVersion="200" />

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
          <Directory Id="MODULEINSTALLLOCATION" Name="Some Repository">
            <Component Id="ServicesHostWindowsService" Guid="257D1FAE-4AFF-4155-BDB8-D81F50E5862B">
              <File Id="ServicesHostInstallerExecutable" KeyPath="yes" DiskId="1" Name="WindowsServiceHost.exe" Source="..\WindowsServiceHost\bin\Output_For_Installer\WindowsServiceHost.exe" />
              <File Id="ServicesHostConfig" KeyPath="no" DiskId="1" Name="WindowsServiceHost.exe.config" Source="..\WindowsServiceHost\bin\Output_For_Installer\WindowsServiceHost.exe.config" />
              <File Id="SomeCompanyCommon" KeyPath="no" DiskId="1" Name="SomeCompany.Common.dll" Source="..\WindowsServiceHost\bin\Output_For_Installer\SomeCompany.Common.dll" />
              <File Id="SomeRepositorySqlScript" KeyPath="no" DiskId="1" Name="SomeRepository.sql" Source="..\..\..\..\..\DB\SomeRepository\SomeRepository.sql" />
              <File Id="LogConfigXml" KeyPath="no" DiskId="1" Name="log.config.xml" Source="..\WindowsService\log.config.xml" />
              <ServiceInstall Id="ServicesHostInstallElement" ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes"
                              Name="AServer WindowsService Host"
                              Description="The windows service responsible for hosting SomeCompany Some Repository's WindowsService."
                                                    />
              <ServiceControl Id="ServicesHostController" Name="AServer WindowsService Host" Remove="uninstall" Start="install" Stop="uninstall" Wait="no" />
            </Component>
          </Directory>
      </Directory>
    </Directory>
    <ComponentGroupRef Id="Product.Generated" /><!-- Harvested by heat -->
  </Module>  
</Wix>
Run Code Online (Sandbox Code Playgroud)

这是wxs的主要产品:

    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="SomeCompanyGlobalDir" Name="SomeCompany Technologies">
      <Directory Id="INSTALLLOCATION" Name="Some Repository">
        <Merge Id='SomeRepositoryPrimaryModule' Language='1033' SourceFile='..\SomeRepositoryMergeModule\bin\Output_For_Installer\SomeRepositoryMergeModule.msm' DiskId='1' />          
      </Directory>
    </Directory>
  </Directory>
</Directory>

<Feature Id="ProductFeature" Title="SomeRepositoryStandaloneInstaller" Level="1">           
  <!-- Note: The following ComponentGroupRef is required to pull in generated authoring from project references. -->            
  <MergeRef Id="SomeRepositoryPrimaryModule"/>
</Feature>

<UIRef Id="WixUI_InstallDir" />
<UIRef Id="WixUI_ErrorProgressText" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" />
Run Code Online (Sandbox Code Playgroud)

当我构建安装程序并运行它时,合并模块中的文件不会进入安装程序UI中用户选择的目录.无论如何,他们都会进入"[Program Files]\SomeCompany Technologies\Some Repository \"目录.

如果我从合并模块目录路径中删除对Program Files的引用,并使用名称为"."的根目录.拿起父MSI的父目录然后合并模块选择用户选择的目录就好了.但是Visual Studio会在构建时抛出一个错误,即收获不起作用,因为路径必须植根于其中一个标准目录中才能使用自动生成的Guids.

那么如何让合并模块在安装时获取用户选择的目录,同时仍然将合并模块路径保持在标准目录中?

Chr*_*ter 6

您正在混淆MSI,因为ProgramFilesFolder是保留的属性名称.将该值更改为"MergeRedirectFolder",并凭借ID为INSTALLLOCATION MergeRedirectFolder的Directory元素下的Merge元素将与INSTALLLOCATION关联.然后,目录Some Repository([MODULEINSTALLLOCATION])将成为INSTALLLOCATION的子目录.

也可以随时查看CodePlex上的ISWIX项目.它对于创建和维护合并模块很有用,并且示例源代码与您在此处尝试执行的操作相关.

  • FWIW,我从根本上反对"收获".当你要求计算机找出你的依赖关系并在构建时为你编写它们而不是你自己做它并且知道它只会在你想要的时候改变时,有很多东西可能会出错. (2认同)