You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Wix的ExePackage中添加指定结构的依赖文件夹?

问题:Wix Bundle打包依赖特定文件结构的驱动实现方案

我正在简化一款遗留WinForms应用的安装流程,该应用对应硬件需安装三个驱动,计划用Wix Bundle打包所有内容。其中一个驱动依赖特定文件结构,且无法修改其.inf文件调整数据查找路径,因此安装程序内需保留该结构。目前手动编写XML代码未取得成功,请问是否可实现?求实现思路。

用户提供的原始代码:

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal ="http://wixtoolset.org/schemas/v4/wxs/bal">
  <Bundle Name="MINEiMiniSetupBundle" Manufacturer="TODO Manufacturer" Version="1.0.0.0" UpgradeCode="ba8f7558-8d8e-497c-95c7-aca4bc5cb362">
    <BootstrapperApplication>
      <bal:WixStandardBootstrapperApplication LicenseUrl="https://www.example.com/license" Theme="hyperlinkLicense" />
    </BootstrapperApplication>

    <Chain>
        <ExePackage Id="FirstDriver" SourceFile="firstInstaller.exe" Permanent="yes"/>
        <ExePackage Id="SecondDriver" SourceFile="secondInstaller.exe" Permanent="yes" />
        <ExePackage Id="dpInstaller" SourceFile="\driver64.exe" Permanent="yes">
            <Payload SourceFile="\DPInst.xml" />
            <Payload SourceFile="\Drivers\ftdibus.cat" />
            <Payload SourceFile="\Drivers\ftdibus.inf" />
            <Payload SourceFile="\Drivers\ftdiport.cat" />
            <Payload SourceFile="\Drivers\ftdiport.inf" />
            <Payload SourceFile="\Data\eula0409.txt" />
            <Payload SourceFile="\Drivers\i386\ftser2k-i386.sys" />
            <Payload SourceFile="=\Drivers\i386\ftserui2-i386.dll" />
            <Payload SourceFile="=\Drivers\i386\ftcserco-i386.dll" />
            <Payload SourceFile="\Drivers\amd64\ftser2k-amd64.sys" />
            <Payload SourceFile="\Drivers\amd64\ftserui2-amd64.dll" />
            <Payload SourceFile="\Drivers\amd64\ftcserco-amd64.dll" />          
        </ExePackage>
        <MsiPackage Id="MainAppMSI" SourceFile="\Release_Online\GSM_Control_4_0_1_28.msi" Permanent="yes" />
        
    </Chain>

  </Bundle>
实现思路与解决方案
  • 问题核心:原始代码里所有Payload只指定了SourceFile,没设置TargetDirectory,Wix默认会把所有文件解压到同一个临时目录,直接破坏了驱动要求的Drivers\i386、Data等层级结构,这是安装失败的根本原因。另外代码里还有几处路径多了等号的低级错误。

  • 修复步骤:

    1. 给每个Payload添加TargetDirectory属性,严格还原原始文件结构:
      • 根目录文件(如DPInst.xml)设置TargetDirectory="."
      • Drivers目录下的文件设置TargetDirectory="Drivers"
      • Drivers\i386子目录下的文件设置TargetDirectory="Drivers\i386"
      • Data目录下的文件设置TargetDirectory="Data"
    2. 修正路径错误:把SourceFile="=\Drivers\..."里的等号删掉,改成SourceFile="\Drivers\..."
    3. 建议使用相对路径代替绝对路径(比如把\driver64.exe改成driver64.exe,前提是该文件和wxs脚本在同一目录),避免系统路径依赖问题
  • 修正后的示例代码:

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal ="http://wixtoolset.org/schemas/v4/wxs/bal">
  <Bundle Name="MINEiMiniSetupBundle" Manufacturer="TODO Manufacturer" Version="1.0.0.0" UpgradeCode="ba8f7558-8d8e-497c-95c7-aca4bc5cb362">
    <BootstrapperApplication>
      <bal:WixStandardBootstrapperApplication LicenseUrl="https://www.example.com/license" Theme="hyperlinkLicense" />
    </BootstrapperApplication>

    <Chain>
        <ExePackage Id="FirstDriver" SourceFile="firstInstaller.exe" Permanent="yes"/>
        <ExePackage Id="SecondDriver" SourceFile="secondInstaller.exe" Permanent="yes" />
        <!-- 使用相对路径,确保driver64.exe与wxs脚本同目录 -->
        <ExePackage Id="dpInstaller" SourceFile="driver64.exe" Permanent="yes">
            <!-- 根目录文件 -->
            <Payload SourceFile="DPInst.xml" TargetDirectory="." />
            <!-- Drivers根目录下的文件 -->
            <Payload SourceFile="Drivers\ftdibus.cat" TargetDirectory="Drivers" />
            <Payload SourceFile="Drivers\ftdibus.inf" TargetDirectory="Drivers" />
            <Payload SourceFile="Drivers\ftdiport.cat" TargetDirectory="Drivers" />
            <Payload SourceFile="Drivers\ftdiport.inf" TargetDirectory="Drivers" />
            <!-- Data目录下的文件 -->
            <Payload SourceFile="Data\eula0409.txt" TargetDirectory="Data" />
            <!-- Drivers\i386子目录文件 -->
            <Payload SourceFile="Drivers\i386\ftser2k-i386.sys" TargetDirectory="Drivers\i386" />
            <Payload SourceFile="Drivers\i386\ftserui2-i386.dll" TargetDirectory="Drivers\i386" />
            <Payload SourceFile="Drivers\i386\ftcserco-i386.dll" TargetDirectory="Drivers\i386" />
            <!-- Drivers\amd64子目录文件 -->
            <Payload SourceFile="Drivers\amd64\ftser2k-amd64.sys" TargetDirectory="Drivers\amd64" />
            <Payload SourceFile="Drivers\amd64\ftserui2-amd64.dll" TargetDirectory="Drivers\amd64" />
            <Payload SourceFile="Drivers\amd64\ftcserco-amd64.dll" TargetDirectory="Drivers\amd64" />          
        </ExePackage>
        <MsiPackage Id="MainAppMSI" SourceFile="Release_Online\GSM_Control_4_0_1_28.msi" Permanent="yes" />
    </Chain>
  </Bundle>

内容的提问来源于stack exchange,提问作者Rej Fredericks

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 23:52:57