我正在尝试使用 WiX Toolset v4 为 HelloWorld WPF 应用程序创建一个 msi 安装程序。 我的问题是缺少 dll,该 dll 未随 msi 安装一起推出。
我刚刚通过 Visual Studio 2022“MSI 包 (WiX v4)”模板创建了一个 WiX MSI 包并完成了两个步骤:
此时的 wxs 文件:
示例组件.wxs
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<ComponentGroup Id="ExampleComponents" Directory="INSTALLFOLDER">
<Component>
<File Source="WpfApp.exe" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
文件夹.wxs
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<StandardDirectory Id="ProgramFiles6432Folder">
<Directory Id="INSTALLFOLDER" Name="!(bind.Property.Manufacturer) !(bind.Property.ProductName)" />
</StandardDirectory>
</Fragment>
</Wix>
包.wxs
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="WpfAppPackage" Manufacturer="TODO Manufacturer" Version="1.0.0.0" UpgradeCode="32058e2f-46ed-4823-9795-d68433888c7f">
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
<Feature Id="Main">
<ComponentGroupRef Id="ExampleComponents" />
</Feature>
</Package>
</Wix>
构建会生成 msi、wixpdb 和 cab1.cab 文件。 要运行 msi 文件,会在 C:/Program Files (x86)/... 下生成一个带有 WpfApp.exe 的新文件夹,但我预计还需要必要的 WpfApp.dll,但此时缺少该文件夹。
尝试启动 WpfApp.exe 只会得到一个事件日志条目,这证实了我的假设。
那么如何配置我的项目以在安装过程中添加 dll?
您需要更新您告诉它安装的组件。最简单的方法是手动将您要添加的文件添加到
ComponentGroup
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<ComponentGroup Id="ExampleComponents" Directory="INSTALLFOLDER">
<Component>
<File Source="WpfApp.exe" />
<File Source="WpfApp.dll"/> <!-- Add this line with the path to your other file -->
</Component>
</ComponentGroup>
</Fragment>
</Wix>