tags:

views:

291

answers:

1

I am struggling to enable the major upgrade functionality in WiX.

I want every new version of the installer to be a major upgrade (full uninstall, then new install) as we don't want different upgrade and clean install versions.

I started off trying to do it using the tag stuff, but I kept getting "Another version is installed." error message when I run the installer.

So I implemented the new tag that was added in V3.5 to make upgrades easier. I was still getting the error message.

I then read somewhere that you need to change the Id GUID for each new version. So I set Id="*" to get WiX to generate them.

Now when I install the newer version it doesn't uninstall the older version, and you end up with two installations to the same folder. I worked this out because running either MSI (new or old) would bring up the repair/remove screen.

Also the program was not overwritten with the new version.

Here is the start of my WiX script:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;

    <Product Id="*"
             Name="Foo"
             Language="1033"
             Codepage="1252"
             Version="!(bind.FileVersion.Foo.exe)"
             Manufacturer="Foo Bar Ltd."
             UpgradeCode="dac2fab2-7d76-4e47-b25f-0748380dab81">

        <Package
                 Description="Foo"
                 Comments="This installer database contains the logic and data required to install Foo."
                 InstallerVersion="300"
                 Languages="1033"
                 SummaryCodepage="1252"
                 Platform="x86"
                 Compressed="yes" />

        <!-- Remove older versions -->
        <!-- Important note: MSI ignores the last version digit 1.0.0.? when comparing versions, so always change at least the 3rd digit for new external releases-->
        <MajorUpgrade DowngradeErrorMessage="The version currently installed is newer than the version you are attempting to install."/>
+2  A: 

Here's a snippet of what I use for all my packages, refined over many internal and public releases

<Product Id="*"
         UpgradeCode="$(var.Property_UpgradeCode)"
         Name="!(loc.ApplicationName)"
         Language="!(loc.Property_ProductLanguage)"
         Version="$(var.version)"
         Manufacturer="!(loc.ManufacturerName)" >

    <Package Description="!(loc.Package_Description) $(var.version)"
           Comments="!(loc.Package_Comments)"
           Manufacturer="!(loc.ManufacturerName)"
           InstallerVersion="301"
           Compressed="yes"
           InstallPrivileges="elevated"
           InstallScope="perMachine"
           Platform="$(var.ProcessorArchitecture)" />

    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

    <Upgrade Id="$(var.Property_UpgradeCode)">
        <UpgradeVersion OnlyDetect="yes"
                        Minimum="$(var.version)"
                        Property="NEWERVERSIONDETECTED"
                        IncludeMinimum="no" />

        <UpgradeVersion OnlyDetect="no"
                        Maximum="$(var.version)"
                        Property="OLDERVERSIONBEINGUPGRADED"
                        IncludeMaximum="no" />

        <!-- Detect for changes in 4th field only -->
        <UpgradeVersion Property="ANOTHERBUILDINSTALLED"
                 Maximum="$(var.version)" Minimum="$(var.version)"
                 IncludeMinimum="yes" IncludeMaximum="yes" OnlyDetect="yes" />

    </Upgrade>

    <CustomAction Id="CA_BlockOlderVersionInstall" Error="!(loc.LaunchCondition_LaterVersion)" />
    <CustomAction Id="CA_BlockAnotherBuildInstall" Error="!(loc.LaunchCondition_AnotherBuild)" />

    <InstallExecuteSequence>
        <Custom Action="CA_BlockOlderVersionInstall" After="FindRelatedProducts">
            <![CDATA[NEWERVERSIONDETECTED]]>
        </Custom>

        <!-- Prevent installation on 4th version field change only -->
        <Custom Action="CA_BlockAnotherBuildInstall" After="FindRelatedProducts">
            <![CDATA[ANOTHERBUILDINSTALLED]]>
        </Custom>

        <LaunchConditions After="AppSearch" />

        <!-- Schedule RemoveExistingProducts early -->
        <RemoveExistingProducts After="InstallInitialize" />
    </InstallExecuteSequence>

    <InstallUISequence>
        <Custom Action="CA_BlockOlderVersionInstall" After="FindRelatedProducts">
            <![CDATA[NEWERVERSIONDETECTED]]>
        </Custom>

        <!-- Prevent installation on 4th version field change only -->
        <Custom Action="CA_BlockAnotherBuildInstall" After="FindRelatedProducts">
            <![CDATA[ANOTHERBUILDINSTALLED]]>
        </Custom>

        <LaunchConditions After="AppSearch" />
    </InstallUISequence>

    <!-- .... -->

</Product>
sascha

related questions