2016-07-06 189 views
0

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

我的问题是:

如果我不设定产品ID等于*(使用$(var.ProductId)”代替),我得到

此产品的另一个版本已安装。的 安装这个版本不能继续...

如果我将其设置为*然后安装新版本,我安装了两个版本。

我已经创建了一个简单的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> 

坏:结果在控制面板的两个版本。

回答

1

我已经做到了使用GUID为UpgradeCode,但离开产品的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你可以参考微软文档here但要小心,虽然。使用a值,即使安装的应用程序具有较新版本,它也会重新安装应用程序。但是你会发现你的安装程序需要哪些字符。

+0

没有工作。它确实要求我重新启动电脑来完成我以前从未见过的安装。但我仍然在机器上安装了两个版本,而不是最新版本。 – DaImTo

0

试着改变你的<MajorUpgrade>的元素添加到

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

Wix website

当设置为NO(缺省),使用相同的版本在安装产品和升级代码(但不同的产品代码)被MSI视为两种产品。当设置为yes时,WiX设置msidbUpgradeAttributesVersionMaxInclusive属性,该属性告诉MSI将具有相同版本的产品视为主要升级。

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

+0

认为您误解了我只希望安装最新版本的应用程序的部分。这是安装两个版本,我现在已经安装了1.0.0.0和1.2.0.0。我只想安装我的应用程序的一个版本。 – DaImTo