簡體   English   中英

Wix 安裝程序主要升級刪除舊版本之前的自定義操作

[英]Wix installer major upgrade custom action before removing old version

我正在使用 wix 安裝程序(第 3 版),我有一個 1.99 版的 msi 和另一個 2.00 版的 msi。 我的應用程序能夠通過使用一些 arguments 調用它來導入和導出數據庫。我正在嘗試執行重大升級,並嘗試在升級前后調用自定義操作。 現在,自定義操作代碼工作得很好。 問題是,應該在刪除舊版本之前運行的代碼在刪除之后運行,因此無法激活應用程序並生成備份文件。

簡而言之:在刪除舊版本之前,我如何安排自定義操作的時間來完成它們的工作?

我是這樣稱呼他們的:

    <CustomAction Id="doExport"
              Return="check"
              Execute="immediate"
              BinaryKey="ImportExportBinary"
              DllEntry="BeforeInstall" />

    <CustomAction Id="doImport"
                Return="check"
                Execute="immediate"
                BinaryKey="ImportExportBinary"
                DllEntry="AfterInstall" />

  <InstallExecuteSequence>
     <Custom Action="doExport" Before="InstallInitialize"> NOT Installed</Custom>
     <Custom Action="doImport" After="InstallFinalize"> NOT Installed</Custom>
  </InstallExecuteSequence>

編輯:

這是主要的升級代碼:

<MajorUpgrade AllowDowngrades="no" 
                Schedule="afterInstallFinalize"
                DowngradeErrorMessage='Cannot downgrade!' 
                AllowSameVersionUpgrades='yes' ></MajorUpgrade>

我試過使用 CustomAction 元素的“Execute”屬性,但沒有任何結果。

首先,進行升級以創建詳細的日志,以確保您的自定義操作正在運行並被調用。 您已將它們標記為立即運行,因此它們會在系統上的任何更改之前運行,因此將在刪除舊產品之前調用它們。 當您說“代碼很好用”時,您可能是指從交互式帳戶運行它。 但這沒有發生。 您的代碼用完了msiexec.exe進程,工作目錄不是您所期望的,您的代碼可能沒有在正確的位置查找文件,它不會被提升,因此可能無法執行該操作認為可以。 您的代碼有很多機會無法按預期運行。

如果您曾經將它們標記為“延遲”,那么我會明白為什么doExport可能無法正常工作。 我不確定是否沒有看到您的MajorUpgrade元素,但是RemoveExistingProducts的默認計划是afterInstallValidate。 您的自定義操作在InstallInitialize之前進行,因此MSI文件中的實際順序可以很容易地是InstallValidate,RemoveExistingProducts,doExport,InstallInitialize。

和執行舊版本卸載的RemoveExistingProducts在自定義操作之前。

因此,如果您想使用推遲執行,請在doExport上嘗試Before =“ RemoveExistingProducts”,或在MajorUpgrade中使用Schedule進行afterInstallInitialize並在dodport之前保留inInstallInitialize。

我試過同樣的東西,但我花了很長時間才找到一種方法讓它起作用。 您可以使用

<Custom Action="doExport" Before="RemoveExistingProducts"></Custom>

選項RemoveExistingProducts是指卸載產品現有版本的操作,因此您必須在刪除現有版本之前執行該操作。

我沒有在此列表中找到此選項: https://learn.microsoft.com/en-us/windows/win32/msi/suggested-installexecutesequence

但它似乎有效,並且在鏈接中描述的選項列表之前執行。

關於<Custom></Custom>標簽內應該是 go 的選項,我不確定,但我希望它有助於在正確的時刻啟動代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM