2

我想要一个引导程序在安装我的setup.msi之前安装.NET 4.5(如果不可用)。如果机器有 .NET 4.5,那么我只想安装产品 setup.msi。

以下是我的代码:

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

    <Bundle Name="AAA" Version="1.0.0.0"  UpgradeCode="8DA460D6-B4CB-4ED0-A1FE-44F269070647">
        <BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost">
        </BootstrapperApplicationRef>

        <Chain>
            <PackageGroupRef Id="Netfx45FullP"/>

            <MsiPackage Compressed="yes" Vital="yes"  Id="PMService" Cache="yes" Visible="no"
                SourceFile="C:\Users\abc.msi">
            </MsiPackage>
        </Chain>
    </Bundle>

    <Fragment>
        <WixVariable Id="WixMbaPrereqPackageId" Value="Netfx45Full" />
        <WixVariable Id="WixMbaPrereqLicenseUrl" Value="NetfxLicense.rtf" />

        <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4FullVersion" />
        <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4x64FullVersion" Win64="yes" />

        <PackageGroup Id="Netfx45FullP">
            <ExePackage Id="Netfx45" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes"
                        InstallCommand="/q"
                        SourceFile="dotNetFx45_Full_x86_x64.exe"
                        DetectCondition="(Netfx4FullVersion=&quot;4.5.50709&quot;) AND (NOT VersionNT64 OR (Netfx4x64FullVersion=&quot;4.5.50709&quot;))"
                        InstallCondition="(VersionNT >= v6.0 OR VersionNT64 >= v6.0) AND (NOT (Netfx4FullVersion=&quot;4.5.50709&quot; OR Netfx4x64FullVersion=&quot;4.5.50709&quot;))"/>
        </PackageGroup>
    </Fragment>
</Wix>
4

1 回答 1

2

您需要删除AND (NOT (Netfx4FullVersion=&quot;4.5.50709&quot; OR Netfx4x64FullVersion=&quot;4.5.50709&quot;)安装条件的一部分。

检测条件将处理判断是否安装了 .NET Framework 的情况。如果检测到已安装,则不会再次安装。

安装条件将确定是否应允许软件包在机器上。如果它评估为假,则将从机器上卸载包。

通过将检测条件添加到安装条件,您基本上可以确保软件包可以安装在机器上并留在机器上。:)

于 2013-03-18T13:52:22.030 回答