2016-07-06 188 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