如何在WiX中指定所需的最低.NET框架版本

5

我的应用程序编译基于.NET 2.0框架,但我希望用户能够在Windows 8上安装它而不会提示安装.NET 3.5。为了提供一些背景信息,我有以下的app.config文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0"/>
        <supportedRuntime version="v2.0.50727"/>
    </startup>
    <runtime>
      <NetFx40_LegacySecurityPolicy enabled="true"/>
    </runtime>
</configuration>

我的问题是,在WiX .wxs文件中,我需要指定应用程序将运行的每个版本的框架吗,例如:

<PropertyRef Id="NETFRAMEWORK20"/>
<Condition Message="This application requires .NET Framework 2.0. Please install the .NET Framework then run this installer again.">
  <![CDATA[Installed OR NETFRAMEWORK20 OR NETFRAMEWORK30 OR NETFRAMEWORK35_CLIENT OR NETFRAMEWORK35 OR NETFRAMEWORK40CLIENT OR NETFRAMEWORK40FULL OR NETFRAMEWORK45]]>
</Condition>

或者,我可以简写它并指定类似于这样的内容吗:
<PropertyRef Id="NETFRAMEWORK20"/>
<Condition Message="This application requires .NET Framework 2.0. Please install the .NET Framework then run this installer again.">
  <![CDATA[Installed OR NETFRAMEWORK20 OR NETFRAMEWORK40CLIENT]]>
</Condition>
1个回答

1
使用bootstrapper时,您可以检查Windows版本和.NET版本,例如在此处:
<ExePackage Id="Netfx45Xxx" Cache="no" Compressed="no" PerMachine="yes" Permanent="yes" Vital="no" InstallCommand="/q"
SourceFile="..\SetupProject\dotnetfx45_full_x86_x64.exe"
DetectCondition="(Netfx4FullVersion=&quot;4.5.50709&quot;) AND (NOT VersionNT64 OR (Netfx4x64FullVersion=&quot;4.5.50709&quot;))" 
InstallCondition="(VersionNT &gt;= v6.0 OR VersionNT64 &gt;= v6.0) AND (NOT (Netfx4FullVersion=&quot;4.5.50709&quot; OR Netfx4x64FullVersion=&quot;4.5.50709&quot;))" />

所以,您可以看到有检测条件和安装条件,它们检查Windows版本和.Net版本。

请纠正我,但是看起来这个语句试图安装 .NET 4.5,而这不是我的目标。 - CtrlDot
逻辑是相同的,您可以安装您的setup.exe文件而不是我的情况下的源文件.net 4.5文件。而且,您可以检查.net 2.0而不是检查.net 4.5和Windows XP,这样您就不会收到任何其他提示了。 - Gilad

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接