【问题标题】:How do I reference a Dynamically named MSI file in a Wix Bundle如何在 Wix Bundle 中引用动态命名的 MSI 文件
【发布时间】:2015-03-18 11:50:52
【问题描述】:

我正在使用 Wix 3.9 并让它构建 3 个 MSI 文件,然后构建一个包含连续每个 MSI 文件的 Bundle。我已经使用herehere 描述的技术升级了主安装程序项目以在MSI 文件名中自动包含版本号。我的 Wix 项目中的 BeforeBuild 任务如下(来自第二个链接)

<!-- Set Output file name to include version-->
<Target Name="BeforeBuild">
  <GetAssemblyIdentity AssemblyFiles="$(SolutionDir)WindowsClient\bin\$(Configuration)\MyApp.exe">
    <Output TaskParameter="Assemblies" ItemName="AssemblyVersions" />
  </GetAssemblyIdentity>
  <CreateProperty Value="$(OutputName)%(AssemblyVersions.Version)">
    <Output TaskParameter="Value" PropertyName="TargetName"/>
  </CreateProperty>
  <CreateProperty Value="$(TargetName)$(TargetExt)">
    <Output TaskParameter="Value" PropertyName="TargetFileName"/>
  </CreateProperty>
  <CreateProperty Value="$(TargetDir)$(TargetFileName)">
    <Output TaskParameter="Value" PropertyName="TargetPath"/>
  </CreateProperty>
</Target>`

但这导致我的包在下一行失败。

<MsiPackage Id="MyMsiFile" Name="$(var.WixInstaller.TargetFileName)" SourceFile="$(var.WixInstaller.TargetDir)"/>

它无法找到文件 MyMsiFile.msi,这是真的,因为它现在被命名为 MyMsiFile1.0.1.msi。如何在 Bundle 文件中使用动态名称引用 MSI 文件?

【问题讨论】:

    标签: wix windows-installer


    【解决方案1】:

    这是一种方法……

    修改生成 MyMsiFile MSI 文件的项目以生成一个 MyMsiFile.wxs,该文件定义了一个 PackageGroup,其中包含具有当前名称的包。

    然后对于需要它的捆绑项目,将 MyMsiFile.wxs 添加为 linked 文件并在其捆绑链中,使用 PackageGroupRef 引用 MSI。

    此方法保留 MSI 项目中的 MSI 包的详细知识,远离捆绑项目。

    【讨论】:

    • 您能否提供答案第一部分的代码/链接?
    • 如何创建 MSI 文件的文件名?
    • 使用我在问题中提供的第二个链接中的“BeforeBuild”方法。
    【解决方案2】:

    我最终一起回避了这个问题。我更改了我的 msi 项目以复制 msi 并将版本号附加到副本中。这样我得到一个带有版本号的 msi 文件和一个没有捆绑到更完整安装程序中的文件。我删除了上面发布的 BeforeBuild 代码并用这个替换它

    <Target Name="AfterBuild">
      <GetAssemblyIdentity AssemblyFiles="$(SolutionDir)WindowsClient\bin\$(Configuration)\MyApp.exe">
        <Output TaskParameter="Assemblies" ItemName="AssemblyVersions" />
      </GetAssemblyIdentity>
      <Copy SourceFiles=".\bin\$(Configuration)\$(OutputName).msi" DestinationFiles=".\bin\$(Configuration)\$(OutputName)%(AssemblyVersions.Version).msi" />
    </Target>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      • 2020-01-28
      • 1970-01-01
      相关资源
      最近更新 更多