我目前在WiX安装程序项目中使用以下标记来检查是否安装了.NET Framework 4.5或更高版本。
<PropertyRef Id="NETFRAMEWORK45" />
<Condition Message="$(var.ProductName) requires .NET Framework 4.5 or higher.">
<![CDATA[Installed OR (NETFRAMEWORK45 >= "#393295")]]>
</Condition>
如何检查.NET Framework 4.6.1 及更高版本?
我正在使用WiX 3.10.2.2516。
答案 0 :(得分:21)
怎么样:
<PropertyRef Id="WIX_IS_NETFRAMEWORK_461_OR_LATER_INSTALLED" />
<Condition Message="$(var.ProductName) requires .NET Framework 4.6.1 or higher.">
<![CDATA[Installed OR WIX_IS_NETFRAMEWORK_461_OR_LATER_INSTALLED]]>
</Condition>
答案 1 :(得分:11)
我担心以上都不适合我。或许我也不太了解如何实施这些建议。
然而,对我来说有用的是我之前检查的.Net Framework 4.5.1要求,类似于您对4.5的检查。
只需将版本更改为目标.Net Framework版本号到所需的版本号,在此处找到:https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx,对我有用。
我最终得到了这个:
<PropertyRef Id="NETFRAMEWORK45"/>
<Condition Message="This application requires .NET Framework 4.6.1. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR (NETFRAMEWORK45 >= "#394254")]]>
</Condition>
P.S。我今天实施了更改,因此接下来几天的测试将向我揭示它是否有效。当我要分享一些结果时,会更新我的评论。
P.P.S。测试取得了我的成功。安装程序在没有安装.Net Framework 4.6.1的环境中成功失败,并成功安装。 (另外:感谢@RamenChef,编辑我的帖子:+1:)
答案 2 :(得分:7)
更新:目前稳定版的WiX现已集成;如果出于某种原因,您使用的是旧版本(例如3.10.3,这是最初编写的最新版本),则可能会对此答案感兴趣
当前版本的WiX(3.10.3)不支持此属性,当前3.10.x每晚构建(3.10.3.3007)也没有 - 它看起来确实像3.11.0.960支持它,但是build没有标记为生产就绪,因此它不适合我的方案。
我最终做的是抓取NetFx461.wxs(here)的源代码,并稍微修改后将其添加到我的3.10版本项目中(见下文)。之后我就可以使用这个属性了。如果需要,您可以对4.6.2进行类似的更改。
这是文件:
<?xml version="1.0" encoding="utf-8"?>
<!--
<copyright file="NetFx461.wxs" company="Outercurve Foundation">
Copyright (c) 2004, Outercurve Foundation.
This software is released under Microsoft Reciprocal License (MS-RL).
The license and further copyright text can be found in the file
LICENSE.TXT at the root directory of the distribution.
</copyright>
-->
<!--<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">-->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:wxs="http://wixtoolset.org/schemas/v4/wxs">
<!--
.NET Framework installation state properties
Official documentation can be found at the following location:
.NET Framework 4.5/4.5.1/4.5.2/4.6/4.6.1 - http://msdn.microsoft.com/en-us/library/w0x726c2(v=vs.110).aspx
-->
<?define NetFx461MinRelease = 394254 ?>
<?define NetFx461WebLink = http://go.microsoft.com/fwlink/?LinkId=671728 ?>
<?define NetFx461RedistLink = http://go.microsoft.com/fwlink/?LinkId=671743 ?>
<Fragment>
<PropertyRef Id="WIXNETFX4RELEASEINSTALLED" />
<Property Id="WIX_IS_NETFRAMEWORK_461_OR_LATER_INSTALLED" Secure="yes" />
<SetProperty Id="WIX_IS_NETFRAMEWORK_461_OR_LATER_INSTALLED" Value="1" After="AppSearch">
WIXNETFX4RELEASEINSTALLED >= "#$(var.NetFx461MinRelease)"
</SetProperty>
</Fragment>
<Fragment>
<util:RegistrySearchRef Id="NETFRAMEWORK45"/>
<WixVariable Id="NetFx461WebDetectCondition" Value="NETFRAMEWORK45 >= $(var.NetFx461MinRelease)" Overridable="yes" />
<WixVariable Id="NetFx461WebInstallCondition" Value="" Overridable="yes" />
<WixVariable Id="NetFx461WebPackageDirectory" Value="redist\" Overridable="yes" />
<PackageGroup Id="NetFx461Web">
<ExePackage
InstallCommand="/q /norestart /ChainingPackage "[WixBundleName]" /log "[NetFx461FullLog].html""
RepairCommand="/q /norestart /repair /ChainingPackage "[WixBundleName]" /log "[NetFx461FullLog].html""
UninstallCommand="/uninstall /q /norestart /ChainingPackage "[WixBundleName]" /log "[NetFx461FullLog].html""
PerMachine="yes"
DetectCondition="!(wix.NetFx461WebDetectCondition)"
InstallCondition="!(wix.NetFx461WebInstallCondition)"
Id="NetFx461Web"
Vital="yes"
Permanent="yes"
Protocol="netfx4"
DownloadUrl="$(var.NetFx461WebLink)"
LogPathVariable="NetFx461FullLog"
Compressed="no"
Name="!(wix.NetFx461WebPackageDirectory)NDP461-KB3102438-Web.exe">
<RemotePayload
CertificatePublicKey="52868DFCA6E3AF2632389E6C1EE7D0468D3797D0"
CertificateThumbprint="3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC"
Description="Microsoft .NET Framework 4.6.1 Setup"
Hash="EE88B05232F43B517D4A368F7EE5065CDE7F67FA"
ProductName="Microsoft .NET Framework 4.6.1"
Size="1424328"
Version="4.6.1055.0" />
</ExePackage>
</PackageGroup>
</Fragment>
<Fragment>
<util:RegistrySearchRef Id="NETFRAMEWORK45"/>
<WixVariable Id="NetFx461RedistDetectCondition" Value="NETFRAMEWORK45 >= $(var.NetFx461MinRelease)" Overridable="yes" />
<WixVariable Id="NetFx461RedistInstallCondition" Value="" Overridable="yes" />
<WixVariable Id="NetFx461RedistPackageDirectory" Value="redist\" Overridable="yes" />
<PackageGroup Id="NetFx461Redist">
<ExePackage
InstallCommand="/q /norestart /ChainingPackage "[WixBundleName]" /log "[NetFx461FullLog].html""
RepairCommand="/q /norestart /repair /ChainingPackage "[WixBundleName]" /log "[NetFx461FullLog].html""
UninstallCommand="/uninstall /q /norestart /ChainingPackage "[WixBundleName]" /log "[NetFx461FullLog].html""
PerMachine="yes"
DetectCondition="!(wix.NetFx461RedistDetectCondition)"
InstallCondition="!(wix.NetFx461RedistInstallCondition)"
Id="NetFx461Redist"
Vital="yes"
Permanent="yes"
Protocol="netfx4"
DownloadUrl="$(var.NetFx461RedistLink)"
LogPathVariable="NetFx461FullLog"
Compressed="no"
Name="!(wix.NetFx461RedistPackageDirectory)NDP461-KB3102436-x86-x64-AllOS-ENU.exe">
<RemotePayload
CertificatePublicKey="52868DFCA6E3AF2632389E6C1EE7D0468D3797D0"
CertificateThumbprint="3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC"
Description="Microsoft .NET Framework 4.6.1 Setup"
Hash="83D048D171FF44A3CAD9B422137656F585295866"
ProductName="Microsoft .NET Framework 4.6.1"
Size="67681000"
Version="4.6.1055.0" />
</ExePackage>
</PackageGroup>
</Fragment>
</Wix>
将它(例如NetFx461.wxs)添加到您的WiX安装程序项目中,您就可以访问所需的属性。
答案 3 :(得分:4)
WIX_IS_NETFRAMEWORK_461_OR_LATER_INSTALLED值由FabienLavocat实施,并于一周前根据the GitHub pull request合并
答案 4 :(得分:0)
以下是我解决此问题的方法。我用它来检查.NET 4.7,但它应该适用于所有.NET 4.5+框架版本。
请参阅https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed#net_b以获取有效修订号的列表。
我使用注册表搜索将属性的值设置为.NET 4.x框架的修订版。后来我以众所周知的方式使用这个属性来检查启动条件:
<?define NetFx47MinRelease = 460798 ?>
<Property Id="NETFRAMEWORK47" Value="0" Secure="yes">
<RegistrySearch
Id="RegSearch"
Root="HKLM"
Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
Name="Release"
Type="raw" />
</Property>
<Condition Message="PPG OnBoard requires .NET Framework 4.7 installed.">
<![CDATA[NETFRAMEWORK47 >= "#$(var.NetFx47MinRelease)"]]>
</Condition>
不幸的是,在这种情况下RegistrySearch
返回前缀为'#'字符的DWORD值,这使得它在我的第一次测试中在“大于”条件下无法使用。使用精确的"#$(var.NetFx47MinRelease)"
语法可以比较“大于”。