2016-07-15 91 views
1

我們有一個wix項目。它安裝了兩個Windows服務和一個Windows桌面應用程序,這些應用程序將顯示在任務欄托盤圖標中。這兩項服務的目的是互相監視和桌面應用程序,以便如果任何一項服務沒有運行,另一項服務將啓動它。如果桌面應用程序未運行,則兩項服務中的一項將啓動桌面應用程序。wix:回滾後服務未啓動

我們希望在我們的安裝程序中實施回滾功能,以便在升級到最新版本時如果出現任何錯誤,安裝程序將回滾到以前的現有版本。我們正在使用WixFailWhenDeferred測試回滾。

<CustomActionRef Id="WixFailWhenDeferred" /> 

回滾似乎在測試中工作,安裝回滾到以前的版本。例如,在計算機v8.0.1.0中已安裝,並且在運行以下命令時,它會嘗試安裝v8.0.2.0,但最終會回滾到8.0.1.0。

>msiexec.exe /passive /norestart /i "D:\setup8.0.2.0.msi" /L*vx+ "d:\test\Installlog8.0.2.0.log" WIXFAILWHENDEFERRED=1 
  1. 但是,我們有一個問題。如果8.0.1.0已經安裝在機器中,並且我們雙擊新版本8.0.2.0.msi,那麼它會要求關閉現有的桌面應用程序。我的意思是,它顯示了正在使用的文件對話框。
  2. 在上面的命令行中,如果我們刪除/ passive參數,那麼它還會顯示File in use對話框。
  3. 此外,回滾後服務未啓動。
  4. 那麼,在我們的wix項目中缺少了什麼?

的維克斯代碼

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

的自定義操作

<CustomAction Id="CertificateInstallCustomAction" 
       BinaryKey="CertificateCustomActions.CA.dll" 
       DllEntry="InstallClientCertificate" 
       Execute="deferred" 
       Return="check" 
       Impersonate="no" /> 

<CustomAction Id="CertificateRemoveCustomAction" 
       BinaryKey="CertificateCustomActions.CA.dll" 
       DllEntry="UninstallClientCertificate" 
       Execute="deferred" 
       Return="check" 
       Impersonate="no"/> 

<CustomAction Id="ClientInstallCustomAction" 
       BinaryKey="ClientCustomActions.CA.dll" 
       DllEntry="InstallValidation" 
       Execute="deferred" 
       Return="check" 
       Impersonate="no"/> 

    <CustomAction Id="ClientInstallCustomActionRoll" 
       BinaryKey="ClientCustomActions.CA.dll" 
       DllEntry="InstallValidation" 
       Execute="rollback" 
       Return="ignore" /> 

<CustomAction Id="ClientRemoveCustomAction" 
       BinaryKey="ClientCustomActions.CA.dll" 
       DllEntry="UninstallValidation" 
       Execute="immediate" 
       Return="check"/> 

<CustomAction Id="StartServiceIfNotRunningIdRoll" 
       BinaryKey="ClientCustomActions.CA.dll" 
       DllEntry="StartServiceIfNotRunning" 
       Execute="rollback" 
       Return="ignore" /> 

ClientRemoveCustomAction:此自定義操作是殺卸載前的桌面應用程序。

序列

<CustomAction Id='AlreadyInstalled' Error='You are running the same version of [ProductName] as you are trying to install.' /> 
<CustomActionRef Id="WixFailWhenDeferred" /> 
<InstallExecuteSequence> 
    <!--<RemoveExistingProducts After="InstallInitialize" />--> 
    <Custom Action='AlreadyInstalled' After='FindRelatedProducts'>SAME_VERSION_INSTALLED</Custom> 

    <Custom Action="CertificateInstallCustomAction" After="InstallServices"> 
    (NOT Installed) AND (NOT UPGRADINGPRODUCTCODE) <!-- For install --> 
    </Custom> 
    <Custom Action="CertificateRemoveCustomAction" After="CertificateInstallCustomAction"> 
    (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") <!-- For Unintall--> 
    </Custom> 
    <Custom Action="ClientInstallCustomAction" Before="CertificateInstallCustomAction" > 
    (NOT Installed) AND (NOT UPGRADINGPRODUCTCODE) OR (NOT Installed)<!-- For install--> 
    </Custom> 
    <Custom Action="ClientInstallCustomActionRoll" Before="ClientInstallCustomAction" > 
    (Installed OR NOT Installed) 
    </Custom> 
    <Custom Action='ClientRemoveCustomAction' Before='InstallValidate'> 
    (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") OR (REMOVE) <!-- For Unintall and Upgrade, we need to ask the uninstall password--> 
    </Custom> 
    <Custom Action='StartServiceIfNotRunningIdRoll' After='InstallInitialize'> 
    (Installed) <!--This is only for restart the service in case of Rollback.--> 
    </Custom> 
</InstallExecuteSequence> 

的服務

<ComponentGroup Id="ClientServices" Directory="INSTALLFOLDER"> 
    <Component Id="ABCWD.exe" Guid="*"> 
    <File Id="ABCWD.exe" KeyPath="yes" Source="$(var.ClientSourceDirectory)\ABCWD.exe" /> 
    <wix:ServiceInstall Id="ABCWDServiceInstaller" Type="ownProcess" Name="Service1" DisplayName="Service1" 
         Description="Enforces enterprise instant messaging policy." Start="auto" ErrorControl="normal" Interactive="no" Vital="yes" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 
     <wix:ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall="yes" OnUninstall="no"/> 
     <util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="restart" RestartServiceDelayInSeconds="60" ResetPeriodInDays="1" /> 
    </wix:ServiceInstall> 
    <wix:ServiceControl Id="ABCWDStartService" Start="install" Stop="both" Remove="uninstall" Name="ABCWD" Wait="yes" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" /> 

    </Component> 

    <Component Id="SysABCMon.exe" Guid="*"> 
    <File Id="SysABCMon.exe" KeyPath="yes" Source="$(var.ClientSourceDirectory)\SysABCMon.exe" /> 
    <wix:ServiceInstall Id="SysABCMonServiceInstaller" Type="ownProcess" Name="Service2" DisplayName="Service2" 
         Description="Enforces enterprise instant messaging policy." Start="auto" ErrorControl="normal" Interactive="no" Vital="yes" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> 
     <wix:ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall="yes" OnUninstall="no"/> 
     <util:ServiceConfig FirstFailureActionType="restart" SecondFailureActionType="restart" ThirdFailureActionType="restart" RestartServiceDelayInSeconds="60" ResetPeriodInDays="1" /> 
    </wix:ServiceInstall> 
    <wix:ServiceControl Id="SysABCMonStartService" Start="install" Stop="both" Remove="uninstall" Name="SysABCMon" Wait="yes" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" /> 
    </Component> 
</ComponentGroup> 

回答

0

其實,有一些命中和審判後的解決方案。爲了防止正在使用的文件(或阻止關閉應用程序提示),我們必須爲CA ClientRemoveCustomAction添加條件REMOVE - 它只會殺死桌面應用程序。

<Custom Action='ClientRemoveCustomAction' Before='InstallValidate'> 
(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL") OR (REMOVE) <!-- For Unintall  and Upgrade, we need to ask the uninstall password--> 
</Custom> 

回滾完成後,服務未啓動,因此我們必須添加以下自定義操作以在回滾時啓動服務。 我們需要了解CA應該儘早排序,以便最後在回滾時執行。

<Custom Action='StartServiceIfNotRunningIdRoll' After='InstallInitialize'> 
(Installed) <!--This is only for restart the service in case of Rollback.--> 
</Custom> 

請讓我知道是否有更好的解決方案。