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

时间:2013-12-20 16:09:47

标签: .net wix

我的应用程序是针对.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 个答案:

答案 0 :(得分: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版本。