如何让 WiX 主要升级正常工作?

发布于 2024-08-21 20:10:12 字数 1497 浏览 1 评论 0原文

我正在努力启用 WiX 中的主要升级功能。

我希望安装程序的每个新版本都是重大升级(完全卸载,然后重新安装),因为我们不希望有不同的升级和全新安装版本。

我开始尝试使用标签内容来完成此操作,但我不断收到“已安装另一个版本”的信息。当我运行安装程序时出现错误消息。

所以我实现了V3.5中添加的新标签以使升级更容易。我仍然收到错误消息。

然后我在某处读到您需要更改每个新版本的 ID GUID。所以我设置 Id="*" 让 WiX 生成它们。

现在,当我安装较新版本时,它不会卸载旧版本,并且最终会在同一文件夹中进行两次安装。我解决了这个问题,因为运行 MSI(新的或旧的)都会显示修复/删除屏幕。

该程序也没有被新版本覆盖。

这是我的 WiX 脚本的开头:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人生百味 2024-08-28 20:10:12

这是我在所有包中使用的片段,经过许多内部和公共版本的改进

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

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>
莳間冲淡了誓言ζ 2024-08-28 20:10:12

如果它对发现这个线程的人有任何用处,我也遇到了我刚刚发现的类似问题。

就我而言(仍处于开发安装程序的早期阶段),关键的区别在于,在版本之间,我已从按用户安装切换到按计算机安装。更具体地说,我将以下行添加到我的 Product.wxs 中:

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

我仍在了解 Windows 安装程序的许多特性,但我认为通过以这种方式切换安装类型将具有可比性以多种方式转向互斥的版本控制流(甚至允许并行安装两个相同的版本!)。

遗憾的是 Windows 控制面板没有明确区分每用户安装和所有用户安装。

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.

审判长 2024-08-28 20:10:12

我知道这篇文章很旧并且已得到解答,但是,如果有人遇到此问题,我的升级安装程序会出现问题。升级部分都很好。安装程序将运行,但是以前的版本从未被删除,因此未安装新版本。问题是

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

上面的 Level="0",应该是 Level="1",如下所示:

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

Scott

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文