我正在尝试弄清楚如何将第三方软件 .exe 与我的 wpf 应用程序 .msi 捆绑在一起。我创建了一个 wix 安装程序项目,并正确构建了我的 .msi 文件,现在我想将其与第三方 exe 捆绑在一起。唯一的问题是它需要检测条件。我在 Windows 注册表中找到了安装产品标识符,但我只需要帮助将其构建为我可以使用的条件。这是我到目前为止在我的bundle.wxs 文件中的内容。
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
<Bundle Name="MyProject.Bundle" Manufacturer="Manufacturer" Version="1.0.0.0" UpgradeCode="f52749fb-8d37-4800-9913-e6ee897b50f9">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
<Chain>
<ExePackage Id="ThirdPartySoftware" SourceFile="Drivers\ThirdPartySoftware.exe" Vital="yes" />
<MsiPackage SourceFile="MyProject.Installer\Installs\MyProject-1.0.0.0-Release-x64.msi" />
</Chain>
</Bundle>
<Fragment Id="Product_PreReqs">
<Property Id="ThirdParty" Secure="yes" Value="0">
<RegistrySearch Id="ThirdPartySearch"
Root="HKLM"
Key="SOFTWARE\ThirdParty"
Type="directory"
/>
</Property>
<Property Id="ThirdPartySub1" Secure="yes" Value="0">
<RegistrySearch Id="ThirdPartySub1Search"
Root="HKLM"
Key="SOFTWARE\ThirdParty\ThirdPartySub1"
Type="directory"
/>
</Property>
<Property Id="ThirdPartySub2" Secure="yes" Value="0">
<RegistrySearch Id="ThirdPartySub2Search"
Root="HKLM"
Key="SOFTWARE\ThirdParty\ThirdPartySub1\ThirdPartySub2"
Type="directory"
/>
</Property>
<Property Id="ThirdPartyVersion" Secure="yes" Value="0">
<!-- 3.07.0044 -->
<RegistrySearch Id="ThirdPartyVersionSearch"
Root="HKLM"
Key="SOFTWARE\ThirdParty\ThirdPartySub1\ThirdPartySub2"
Name="Version"
Type="raw"
/>
</Property>
<Property Id="ThirdPartyUninstallVersion" Secure="yes" Value="0">
<!-- 3.07.0044 -->
<RegistrySearch Id="ThirdPartyUninstallVersionSearch"
Root="HKLM"
Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B122EBFB-4345-4AE3-90AE-99C8B9E3F02C}"
Name="DisplayVersion"
Type="raw"
/>
</Property>
</Fragment>
</Wix>
我查看了 wix 网站上的文档,并在 Stack Overflow、Google 和 YouTube 上进行了搜索。我在所有这些提到检测条件的地方都找到了结果,但我还没有找到任何解释如何创建条件或如何进行这些搜索并将它们放入条件变量中的内容。
您必须将搜索结果保存到变量中,并将 DetectCondition 添加到您的 ExePackage 中。
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Bundle Name="MyProject.Bundle" Manufacturer="Manufacturer" Version="1.0.0.0" UpgradeCode="f52749fb-8d37-4800-9913-e6ee897b50f9">
<util:RegistrySearch Id="ThirdPartyVersionSearch"
Variable="ThirdPartyVersion"
Root="HKLM"
Key="SOFTWARE\ThirdParty\ThirdPartySub1\ThirdPartySub2"
Value="Version"
/>
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" />
<Chain>
<ExePackage Id="ThirdPartySoftware" SourceFile="Drivers\ThirdPartySoftware.exe" Vital="yes" DetectCondition="ThirdPartyVersion >= 3.07.0044" />
<MsiPackage SourceFile="MyProject.Installer\Installs\MyProject-1.0.0.0-Release-x64.msi" />
</Chain>
</Bundle>
</Wix>