Programmer
Programmer

Reputation: 400

WiX bootstrapper application

I want a bootstrapper to install .NET 4.5 (if not available) before installing my setup.msi. If the machine has .NET 4.5 then I want to install the product setup.msi only.

Following is my code:

<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>

Upvotes: 2

Views: 1860

Answers (1)

Rob Mensching
Rob Mensching

Reputation: 36026

You'll want to remove the AND (NOT (Netfx4FullVersion=&quot;4.5.50709&quot; OR Netfx4x64FullVersion=&quot;4.5.50709&quot;) part of your install condition.

The detect condition will handle the case of telling if the .NET Framework is installed. If it is detected as installed, it will not be installed again.

The install condition will determine if the package should be allowed to be on the machine or not. If it evaluates to false the package will be uninstalled from the machine.

By adding the detect condition to the install condition your basically making it never true that the package can be installed on the machine and stay on the machine. :)

Upvotes: 2

Related Questions