我有一個Inno安裝腳本,我需要在安裝或替換特定文件之前執行自定義操作。如何檢測文件是否要安裝(或替換)?
的documentation狀態:
如果安裝程序已經確定它不應該被處理記錄A
BeforeInstall
或AfterInstall
函數沒有被調用。
所以我想我可以用BeforeInstall
指定安裝文件之前,應當做什麼,但似乎Inno Setup的需要安裝的文件或不決定調用BeforeInstall
功能後,所以這函數實際上每次都被調用。
如何在安裝文件之前執行操作,但如果文件未安裝(例如,因爲其版本未更改),該如何執行操作?
編輯:
下面的代碼的相關部分:
...
[Files]
...
Source: "..\bin\{#BuildConfig}\FooBar.dll"; DestDir: "{app}"; Flags: uninsrestartdelete; BeforeInstall: PrepareInstallFooBar
...
[Code]
...
procedure PrepareInstallFooBar();
begin
Log(Format('BeforeInstall: %s', [CurrentFileName]));
...
end;
...
下面是該日誌中顯示:
...
2014-03-28 10:40:46.778 BeforeInstall: {app}\FooBar.dll
2014-03-28 10:40:46.778 -- File entry --
2014-03-28 10:40:46.778 Dest filename: C:\Users\tom\AppData\Local\MyApp\bin\FooBar.dll
2014-03-28 10:40:46.778 Time stamp of our file: 2014-03-28 10:35:10.000
2014-03-28 10:40:46.778 Dest file exists.
2014-03-28 10:40:46.778 Time stamp of existing file: 2014-03-28 10:35:10.000
2014-03-28 10:40:46.778 Version of our file: 1.0.0.0
2014-03-28 10:40:46.778 Version of existing file: 1.0.0.0
2014-03-28 10:40:46.778 Same version. Skipping.
...
是什麼讓你認爲Inno Setup決定是否在'BeforeInstall'方法執行後安裝文件? ['源代碼'](https://github.com/jrsoftware/issrc/blob/is-5_5_4/Projects/Install.pas#L1622)顯示了其他內容。只有當條件通過時,纔會注意'ShouldProcessFileEntry'函數的條件以及隨後調用NotifyBeforeInstallFileEntry方法。你能告訴我們一些具體的案例嗎? – TLama
@TLama,我在'BeforeInstall'函數的日誌中寫了一行,我可以看到它總是在IS決定跳過文件之前執行。 –
@TLama,我發佈了代碼和日誌文件的相關部分 –