问题描述
我正在尝试通过条件检查带有 Wix 3.11 的 .net 版本。这在 4.5 之前都可以正常工作:
<PropertyRef Id="NETFRAMEWORK45" />
<Condition Message="This application requires .NET Framework 4.5. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>
检查 .Net 5 似乎是不可能的——至少用这种机制不可能。我该怎么做?
解决方法
NetFx 扩展在构建时注入了 NETFAMEWORK45 属性。它目前不支持 .NET 5。您可以在此处查看其工作原理的源代码:
https://github.com/wixtoolset/Netfx.wixext/tree/master/src/wixlib
不应需要自定义操作来检测 .NET Core。只需编写一个类似于下面的属性/RegSearch,但针对 .NET 5 留下的足迹的详细信息进行了修改。
<Fragment>
<Property Id="NETFRAMEWORK40CLIENT" Secure="yes">
<RegistrySearch Id="NetFramework40Client" Root="HKLM" Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client" Name="Install" Type="raw" />
</Property>
</Fragment>