【问题标题】:Why is my WiX generated msi installing to the wrong directory为什么我的 WiX 生成的 msi 安装到错误的目录
【发布时间】:2021-10-01 22:43:22
【问题描述】:

我正在尝试使用 Wix 命令行工具集编写一个批处理脚本,以从 Heat 生成的文件和自定义 .wxs 文件构建一个 .msi 文件。

下面的批处理脚本目前大部分时间都在正确构建 .msi 文件。但是,在运行时,它会将二进制文件直接安装到 C: 驱动器,而不是将它们安装到自定义 wxs 文件中指定的安装文件夹中。

谁能指出我错过了什么,因为我不知所措。

批处理脚本:

"%WIX%bin\heat" dir .\bin\ -srd -gg -pog:Binaries -cg AppBinComponentGroup -out .\AppHeatGen.wxs
"%WIX%bin\candle" .\*.wxs -o .\wixbuild\wixobj\
"%WIX%bin\light" -b .\bin\ .\wixbuild\wixobj\*.wixobj -o .\wixbuild\wixbin\AppInstaller.msi

自定义 wxs:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="App" Language="1033" Version="1.0.1.0">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
        <MediaTemplate EmbedCab="yes" />

        <Feature Id="ProductFeature" Title="App" Level="1">
            <ComponentGroupRef Id="AppBinComponentGroup" />
        </Feature>
    </Product>

    <Fragment>
    <SetDirectory Id="APPLICATIONFOLDER" Value="C:\InstallDir" />
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="APPLICATIONFOLDER">
        <Directory Id="INSTALLFOLDER" Name="App" />
            </Directory>
        </Directory>
    </Fragment>
</Wix>

【问题讨论】:

  • 我没有看到你在哪里定义了APPLICATIONFOLDER。如果 wix 无法分辨是哪个文件夹,则嵌套文件夹无关紧要。 TARGETDIR 代表可用空间最多的驱动器的根目录(如果有多个驱动器可用),因此在您的情况下似乎是驱动器 C:
  • @peterpie 我认为 SetDirectory 标签定义了 APPLICATIONFOLDER 值。至少,当我通过 MSBuild 构建 wixproj 时,我认为这就是它的工作原理。那我该如何定义那个变量呢?
  • 我很抱歉。我通常从不使用 SetDirectory。如果它按我想的方式工作,那么它会复制根路径,最终类似于“C:\C:\InstallDir\App”。我建议您将设置的目录行更新为&lt;SetDirectory Id="APPLICATIONFOLDER" Value="InstallDir" /&gt;。我通常这样做的方式如下,&lt;Directory Id="TARGETDIR" Name="SourceDir"&gt; &lt;Directory Id="APPLICATIONFOLDER" Name="InstallDir"&gt; &lt;Directory Id="INSTALLFOLDER" Name="App" /&gt; &lt;/Directory&gt; &lt;/Directory&gt;

标签: cmd wix


【解决方案1】:

在使用 wix 脚本尝试不同的事情后,我发现 heat 命令正在将所有组件目录值设置为 TARGETDIR。

修复方法是更新 heat 命令以包含一个带有所需安装文件夹 ID 作为值的 -dr 标签。

"%WIX%bin\heat" dir .\bin\ -dr INSTALLFOLDER -srd -gg -pog:Binaries -cg AppBinComponentGroup -out .\AppHeatGen.wxs

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多