Inno Setup allows you to send logging information to a file during install/uninstall operations. You must specify the log option and destination file on the command line.
Example Installation
The InitializeSetup() function is called shortly after the installer/uninstaller starts. It runs before the user has been prompted for a target folder so {app}
is undefined here. In fact, it runs before [Setup] runs so none of those values are available either.
However, it is a great place to put in checks to make sure the environment is correct to begin work. Inno functions are written in Pascal. Keep Google handy.
#define MyAppName "AmazingApp" #define MyAppDLL MyAppName + ".dll" #define MyAppBuildPath ProjDir + "bin\" + BuildConfiguration + "\" + MyAppDLL ; Use Inno built-in to examine my DLL and get version number. #define MyAppVersion GetVersionNumbersString(MyAppBuildPath) [Setup] ; None of these values in this section are available in InitializeSetup() function. [Code] // // Called during Setup's initialization. Return False to abort Setup, True otherwise. // function InitializeSetup: Boolean; begin Log('InitializeSetup called...'); Log(' * Passed on command line:') Log(' BuildConfiguration: ' + ExpandConstant('{#BuildConfiguration}')); Log(' ProjDir: ' + ExpandConstant('{#ProjDir}')); Log(' * Script defines:') Log(' MyAppName: ' + ExpandConstant('{#MyAppName}')); Log(' MyAppVersion: ' + ExpandConstant('{#MyAppVersion}')); Result := // something that returns true if we should continue the install/uninstall. if not Result then begin MsgBox('Setup requires something you are lacking!', mbError, MB_OK); end; end;
I run the Inno compile step in a Visual Studio Post-build event. First I add the NuGet package “Tools.InnoSetup”. After the project builds successfully, the Post-build step passes information I need in the script via command line then the installer is created. (All text on a single line.)
"$(SolutionDir)packages\Tools.InnoSetup.6.2.0\tools\iscc.exe" /DBuildConfiguration="$(ConfigurationName)" /DProjDir="$(ProjectDir)" "$(ProjectDir)InstallerSetup\Package.iss"
Once I have the installer built, I can start it on the command line. In this case, I’m also creating a log file in the same folder. You would do this if there were any problems or for your development testing.
> MyApp.Setup.exe /log="autolog.txt"
Below are the log file results. Note that I have modified some the lines.
[18:06:53.515] *** Setup started [18:07:06.915] Log opened. (Time zone: UTC-04:00) [18:07:06.921] Setup version: Inno Setup version 6.2.0 [18:07:06.922] Original Setup EXE: ... [18:07:06.924] Setup command line: ... [18:07:06.933] Compatibility mode: Yes (DetectorsAppHealth) [18:07:06.935] Windows version: 10.0.19044 (NT platform: Yes) [18:07:06.937] 64-bit Windows: Yes [18:07:06.939] Processor architecture: x64 [18:07:06.943] User privileges: Administrative [18:07:06.952] Administrative install mode: Yes [18:07:06.953] Install mode root key: HKEY_LOCAL_MACHINE [18:07:06.954] 64-bit install mode: No [18:07:06.972] Created temporary directory: ... [18:07:20.923] InitializeSetup called... [18:07:21.409] * Passed on command line: [18:07:21.646] BuildConfiguration: Release [18:07:21.853] ProjDir: C:\dev\Solution\AmazingApp\ [18:07:22.045] * Script defines: [18:07:22.230] MyAppName: AmazingApp [18:07:22.469] MyAppVersion: 0.9.0.0 [18:07:23.852] Message box (OK): Setup requires something you are lacking! [18:07:27.306] User chose OK. [18:07:28.659] InitializeSetup returned False; aborting. [18:07:28.663] Got EAbort exception. [18:07:28.666] Deinitializing Setup. [18:07:28.746] *** Setup exit code: 1