私たちにはプロジェクトがあります。 2つのWindowsサービスとタスクバーのトレイアイコンに表示されるWindowsデスクトップアプリケーションがインストールされます。これらの2つのサービスの目的は、お互いを監視してデスクトップアプリケーションを監視することで、サービスのいずれかが実行されていない場合は、もう一方のサービスが起動するようにします。また、デスクトップアプリケーションが実行されていない場合は、2つのサービスのいずれかがデスクトップアプリケーションを起動します。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をダブルクリックすると、既存のデスクトップアプリケーションを閉じるように求められます。つまり、「使用中のファイル」ダイアログボックスが表示されます。
- 上記のコマンドラインで、/ passive引数を削除すると、File in useダイアログボックスも表示されます。
- また、ロールバック後にサービスが開始されていません。
- だから、私たちのwixプロジェクトには何か不足していますか?
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>