【问题标题】:Allow Upgrade of Application允许升级应用程序
【发布时间】:2016-07-06 12:34:12
【问题描述】:

我正在尝试允许升级我的应用程序。如果用户安装 1.0.0,那么下次我发布一个版本时,我可以给他们 1.1.0,他们可以安装它。 Overwriting | removing | replacing the first version 控制面板中应该只安装一个版本 -> 卸载或更改程序。

我的问题是:

如果我没有设置产品 ID 等于 *(使用 $(var.ProductId)" 代替)我得到 ​​p>

已安装此产品的另一个版本。安装 此版本无法继续...

如果我将其设置为 *,那么它会安装新版本,并且我安装了两个版本。

我创建了一个简单的 wix 应用程序来测试它。

<?xml version="1.0" encoding="UTF-8"?>
<?define ProductVersion="!(bind.FileVersion.MyAssemblyDll)"?>
<?define UpgradeCode="f4d7f199-28f6-45d5-ad99-7c62938274be"?>
<?define ProductId="{6408D956-40DA-4AEE-883E-5425F1562004}"?>
<?define Version="1.2.0"?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="$(var.ProductId)" Name="UpgradeTest" Language="1033" Version="$(var.Version)" Manufacturer="xxx" UpgradeCode="$(var.UpgradeCode)">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <!-- prevents down gradeing -->
    <!-- one upgrade installes new version first then removes the old one. -->
        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." Schedule="afterInstallExecute"/>
        <MediaTemplate EmbedCab="yes"/>

        <Feature Id="ProductFeature" Title="UpgradeTest" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
                <Directory Id="INSTALLFOLDER" Name="UpgradeTest" />
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
             <Component Id="ProductComponent">
         <File Id="Product.wxs" Source="Product.wxs" KeyPath="yes" />
             </Component> 
        </ComponentGroup>
    </Fragment>
</Wix>

我已经尝试让这个工作好几天了,我已经用尽了所有的教程,可以追溯到 2008 年。任何帮助将不胜感激。

更新:

<MajorUpgrade AllowDowngrades="no" DowngradeErrorMessage="A newer version of [ProductName] is already installed."   AllowSameVersionUpgrades="no" />

不好:在控制面板中产生两个版本。

更新二:

<Upgrade Id ="$(var.ProductUpgradeCode)">
   <UpgradeVersion Minimum="$(var.ProductFullVersion)" OnlyDetect="yes" Property="NEWERVERSIONDETECTED"/>
   <UpgradeVersion Maximum="$(var.ProductFullVersion)" IncludeMaximum="no" Property="OLDERVERSIONBEINGUPGRADED"/>
</Upgrade>


<InstallExecuteSequence>
   <RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>

<Condition Message="A newer version of [ProductName] is already installed. If you are sure you want to downgrade, remove the existing installation via Programs and Features.">Not NEWERVERSIONDETECTED</Condition>

不好:在控制面板中产生两个版本。

【问题讨论】:

    标签: c# wix upgrade


    【解决方案1】:

    我的做法是为UpgradeCode 使用GUID,但将产品的Id 保留在*。 然后将重新安装属性设置为 amus 以按照您想要的方式重新安装您的产品。

    看起来像这样

    <Product Id="*"
           Name="YourProductName"
           Language="1033"
           Version="YourProductVersion"
           Manufacturer="YourCompany"
           UpgradeCode="{SOME-GUID}">
    
    <SetProperty Id="REINSTALLMODE" Value="amus" After="FindRelatedProducts">Installed AND REMOVE&lt;&gt;"ALL"</SetProperty>
    

    对于amus,您可以参考Microsoft 文档here,但要小心。使用a 值,即使安装的应用程序版本较新,它也会重新安装您的应用程序。但是您会弄清楚安装程序需要哪些字符。

    【讨论】:

    • 没用。它确实要求我重新启动电脑以完成我以前从未见过的安装。但我最终还是在机器上安装了两个版本,而不仅仅是最新的。
    【解决方案2】:

    尝试将您的 &lt;MajorUpgrade&gt; 元素更改为此

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." AllowSameVersionUpgrades="yes" Schedule="afterInstallExecute"/>
    

    来自Wix website

    当设置为 no(默认值)时,MSI 允许安装具有相同版本和升级代码(但产品代码不同)的产品,并将其视为两个产品。当设置为 yes 时,WiX 会设置 msidbUpgradeAttributesVersionMaxInclusive 属性,该属性告诉 MSI 将具有相同版本的产品视为主要升级。

    因此,它被视为您的两个安装不相关。我认为这是一种奇怪的行为,但要怪微软。

    【讨论】:

    • 认为您误解了我只希望我的应用程序的一个版本安装最新的部分。这是安装两个版本,我现在安装了 1.0.0.0 和 1.2.0.0。我只想安装我的应用程序的一个版本。
    猜你喜欢
    • 2014-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-24
    • 1970-01-01
    • 2016-01-25
    • 2016-07-26
    相关资源
    最近更新 更多