加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何让WiX主要升级工作?

发布时间:2020-12-13 20:22:57 所属栏目:Windows 来源:网络整理
导读:我正在努力启用WiX的主要升级功能. 我希望安装程序的每个新版本都是一个主要的升级(完全卸载,然后是新安装),因为我们不希望不同的升级和干净的安装版本. 我开始尝试使用标签的东西,但我一直在“安装另一个版本”.运行安装程序时出现错误信息. 所以我实现了V3
我正在努力启用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."/>
这是一个我所用的所有软件包的代码片段,在许多内部和公开发行版本上进行了改进
<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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读