How to get WiX major upgrade working?

2019-01-16 17:28发布

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

    <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."/>

3条回答
Lonely孤独者°
2楼-- · 2019-01-16 17:33

I know this post is old and answered, but, in case anyone runs across this, I had issues with my upgrade installer. The upgrade sections were all fine. The installer would run, but, the previous version was never removed, therefore, the new version was not installed. The issue was this

<Feature Id="ProductBinaries" Title="ProductBinariesInstaller" Level="0">

The Level="0" above, should have been Level="1" as it is below:

<Feature Id="ProductBinaries" Title="ProductBinariesInstaller" Level="1">

Scott

查看更多
倾城 Initia
3楼-- · 2019-01-16 17:33

If it's of any use to those who discover this thread, I've also encountered a similar problem which I've just figured out.

In my case (and still having been in early stages of developing my installer), the critical difference was that, between versions, I had switched from a per-user install to a per-machine install. More specifically, I'd added the following line to my Product.wxs:

<Property Id='ALLUSERS' Value='1'/>

I'm still getting my head around many of the idiosyncrasies of Windows Installers, but I'd assume that by switching the type of installation in this way would be comparable with shifting to a mutually exclusive stream of versioning in many ways (even enabling two identical versions to be installed in parallel!).

It's a shame that the Windows Control Panel doesn't clearly distinguish between installations which are per-user and all-users.

查看更多
Fickle 薄情
4楼-- · 2019-01-16 17:47

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>
查看更多
登录 后发表回答