Have WiX/Burn detect the required version of .NET Framework

故事扮演 提交于 2019-12-23 21:12:16

问题


How can I have Burn detect that the required .NET 4.5 framework is installed and if not notify the user prior to launching my custom UI that the install requires .NET 4.5 to run?

Without the prerequisite check my custom UI (BootStrapperApplication) will fail to load.

I do not want to install only prompt that it is missing.


回答1:


In your Bundle.wxs file (or where ever you have the <Bundle> defined), add this:

<bal:Condition Message="Add your message here">NETFRAMEWORK40FULL</bal:Condition>

For example, I use the following message to provide a clickable link the user can use to download the needed installer:

<?define NetFx40WebLink = http://go.microsoft.com/fwlink/?linkid=182805 ?>
<bal:Condition Message="Microsoft .NET 4 Full Framework is required. Please download and install it from &lt;a href=&quot;$(var.NetFx40WebLink)&quot;&gt;$(var.NetFx40WebLink)&lt;/a&gt; then re-run this installer.">NETFRAMEWORK40FULL</bal:Condition>

And the result looks like this:




回答2:


The currently accepted answer doesn't actually work, as MSI properties aren't available in a bundle.

This example checks for .NET Framework 4.6.1. Add references to the NetFxExtension and UtilExtension in your Wix tag:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" 
 xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

Define some properties indicating the .NET version you require (I found the release by trawling through this repo):

<?define NetFx461MinRelease = 394254 ?>
<?define NetFx461WebLink = http://go.microsoft.com/fwlink/?LinkId=671728 ?>

Finally, inside your bundle reference the registry check from the NetFx Extension and then perform the check manually.

<util:RegistrySearchRef Id="NETFRAMEWORK45"/>

<bal:Condition Message="This product requires .NET Framework 4.6.1, please install it from &lt;a href=&quot;$(var.NetFx461WebLink)&quot;&gt;$(var.NetFx461WebLink)&lt;/a&gt;.">
  <![CDATA[NETFRAMEWORK45 >= $(var.NetFx461MinRelease)]]>
</bal:Condition>


来源:https://stackoverflow.com/questions/18771523/have-wix-burn-detect-the-required-version-of-net-framework

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!