2014-01-28 218 views
0

我已經創建了一個Wix安裝程序,用於替換在Visual Studio中創建的安裝程序,並且應該更新它正在安裝的軟件的先前版本。我一直認爲是在以前版本的安裝礦用同樣的升級代碼,所以我認爲這個代碼將工作:Wix 3.8:安裝程序不卸載以前的版本或安裝新版本

<?xml version="1.0" encoding="utf-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 

    <Product Id="*" 
     Name="Product" 
     Language="1033" 
     Version="1.0.6.0" 
     Manufacturer="Company" 
     UpgradeCode="PREVIOUSLY-USED-UPGRADE-CODE"> 
    <Package InstallerVersion="301" 
      Compressed="yes" 
      InstallScope="perMachine" 
      Manufacturer="Company" 
      Description="Installs Product" 
      Keywords="Installer,MSI" /> 
    <Media Id="1" 
      Cabinet = "Product.cab" 
      EmbedCab = "yes"/> 

    <MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A newer version of Product is already installed." AllowDowngrades="no"/> 

    <Directory Id ="TARGETDIR" Name="SourceDir"> 
     <Directory Id="ProgramFilesFolder"> 
     <Directory Id="CompanyFolder" Name ="Company"> 
      <Directory Id="INSTALLDIR" Name="Product" /> 
     </Directory> 
     </Directory> 
    </Directory> 

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

    <ComponentGroup Id="ProductComponents" Directory="INSTALLDIR"> 

     <Component Id="cmpCOMAdminW2K" Guid="*"> 
     <File Id="COMAdminW2K" Vital="yes" KeyPath="yes" Name="Interop.COMAdminW2K.dll" Source="Local\Path\To\Interop.COMAdminW2K.dll" /> 

     <!-- Several registry entry updates --> 
     </Component> 

     <Component Id="cmpCustomSerializer" Guid="*"> 
     <File Id="CustomSerializer" Vital="yes" KeyPath="yes" Name="AREANAME.Serialization.CustomSerializer.v2.0.dll" Source="Local\Path\To\AREANAME.Serialization.CustomSerializer.v2.0.dll" /> 
     </Component> 

     <Component Id="cmpProductServer" Guid="*"> 
     <File Id="ProductServer" Vital="yes" KeyPath="yes" Name="AREANAME.ProductServer.Shared.v2.0.dll" Source="Local\Path\To\AREANAME.ProductServer.Shared.v2.0.dll" /> 
     </Component> 

     <Component Id="cmpRemotingHelper" Guid="*"> 
     <File Id="RemotingHelper" Vital="yes" KeyPath="yes" Name="AREANAME.TechPC.RemotingHelper.v2.0.dll" Source="Local\Path\To\ND1.TechPC.RemotingHelper.v2.0.dll" /> 
     </Component> 

     <Component Id="cmpProduct" Guid="*"> 
     <File Id="Product" Vital="yes" KeyPath="yes" Name="AREANAME.TechPC.Service.Product.v2.0.exe" Source="Local\Path\To\AREANAME.TechPC.Service.Product.v2.0.exe" /> 
     <ServiceInstall 
      Id="Product" 
      Name="ServiceName" 
      DisplayName="Full Service Name" 
      Start="auto" 
      ErrorControl="normal" 
      Type="ownProcess"/> 

     <ServiceControl 
      Id="startAndStopUsrPres" 
      Name="ServiceName" 
      Start="install" 
      Stop="both" 
      Remove="uninstall" 
      Wait="yes"/> 
     </Component> 

     <Component Id="cmpProductConfig" Guid="*"> 
     <File Id="ProductConfig" Vital="yes" KeyPath="yes" Name="AREANAME.TechPC.Service.Product.v2.0.exe.config" Source="Local\Path\To\AREANAME.TechPC.Service.Product.v2.0.exe.config" /> 
     <RemoveFile Id="RemoveProductConfig" Name="AREANAME.TechPC.Service.Product.v2.0.exe.config" On ="install"/> 
     </Component> 

     <Component Id="VersionRegistryEntry" Guid="*"> 
     <RegistryKey Root="HKLM" 
        Key="Software"> 

      <RegistryKey Key="Company" 
         ForceCreateOnInstall="yes"> 

      <RegistryKey Key="Product" 
         ForceCreateOnInstall="yes"> 

       <RegistryValue Id="ProductVersionEntry" 
       KeyPath ="yes" 
       Action ="write" 
       Name="Version" 
       Value="1.0.6.0" 
       Type="string"/> 

      </RegistryKey> 
      </RegistryKey> 
     </RegistryKey> 

     </Component> 
    </ComponentGroup> 
    </Product> 
</Wix> 

*上面的代碼是明顯的節錄。

安裝程序將通過一個軟件管理系統運行幾乎所有我公司的機器,所以我一直在用下面的命令行測試我的安裝程序:

msiexec.exe /i <ProductInstaller>.msi /quiet /l*v log.txt 

這使我想到問題。你們中的一些人可能已經注意到,在包含我的配置文件的組件內部有一個「RemoveFile」標籤。我有它,因爲安裝程序運行時該文件並不總是得到更新。這與MajorUpgrade計劃相結合,允許我將該文件從目標目錄中刪除,並確保新的配置文件始終處於該位置。該修復似乎在我的測試中起作用。無論何時我試圖在具有該程序以前版本的計算機上運行安裝程序時,程序文件都顯得正確無誤。但是,即使所有正確的文件位於正確的位置,服務也不會自動啓動,或者通過手動嘗試在services.msc中啓動它。此外,每當我試圖運行下面的卸載:

msiexec.exe /x <ProductInstaller>.msi /quiet /l*v log.txt 

我收到錯誤消息「此操作只適用於當前已安裝的產品。」

我不知道該怎麼做,因爲新文件是他們應該是的地方,舊文件已經消失。

有了所有這些信息,我的問題有些含糊:「我錯過了一個安裝程序,它將所有文件放在適當的位置並在安裝時啓動服務,並停止服務並刪除卸載文件?「

任何協助將不勝感激,我很樂意根據請求向任何認爲他們會幫助我找出問題的人提供日誌文件的部分內容。

謝謝! -Seth

+0

嗯,我想我發現了爲什麼服務不會啓動。不知何故,主dll依賴的我的一個程序集在安裝後被重命名。這解決了這個錯誤。一旦我解決了問題,我們會看看是否還有其他問題。 – Neverforget115

回答

相關問題