【问题标题】:WiX - Set Merge Module Directory at Install Time?WiX - 在安装时设置合并模块目录?
【发布时间】:2012-05-24 17:32:36
【问题描述】:

我已经按照入门 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>

这是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" />

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

如果我从合并模块目录路径中删除对 Program Files 的引用并使用名称为“。”的根目录。拾取父 MSI 的父目录,然后合并模块拾取用户选择的目录就好了。但随后 Visual Studio 会在构建时抛出一个错误,即无法收集,因为路径必须植根于标准目录之一才能使用自动生成的 Guid。

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

【问题讨论】:

  • 顺便说一句,我尝试将 ConfigurableDirectory 添加到值为 INSTALLLOCATION 的功能标记中,但它仍然没有拾取目录...

标签: wix wix3.5 merge-module


【解决方案1】:

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

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

【讨论】:

  • 感谢您的回复!所以这就是问题所在。我正在使用 Visual Studio 的热收集集成。当我删除 ProgramFilesFolder 并将其替换为 MergeRedirectFolder 时,我收到以下错误:组件“cmpFBB3C43EFF7EC66E72A4BA7150FEFCD0”具有路径为“TARGETDIR\some_path\some_file.ext”的密钥文件。由于此路径未植根于标准目录之一(如 ProgramFilesFolder),因此此组件不符合自动生成 guid 的标准。我怎样才能同时:做出改变并继续使用内置收获?
  • 这个问题与收获无关。
  • 是的。但由于收获问题,我无法应用您之前的解决方案。我试图验证您的解决方案但未能成功,因为 Visual Studio / heat 似乎觉得用 MergeRedirectFolder 替换 ProgramFilesFolder 现在会使组件在标准目录中无根。
  • 上面的答案确实解决了安装时安装目录的映射问题。但是,对于那些尝试使用 Visual Studio 的内置收获的人来说,这个解决方案可能不适合你。我可能会打开一个后续问题来尝试解决问题的一半。
  • FWIW,我从根本上反对“收获”。当您要求计算机找出您的依赖关系并在构建时为您编写它们而不是您自己做并且知道它只会在您想要的时候改变时,有很多事情可能会出错。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多