Hello Krishna,
Indeed, you are right. It seems that when I have tested this, I went on a wrong route (I misunderstood your scenario). The
[MsiLogFileLocation] property stores the full path to the log file of the main package (e.g. "F:\temp\msilog.txt") not the general path (e.g. "F:\temp"). This is why it did not work the way you were trying. This is happening because, basically, the chained package's log was trying to overwrite the earlier created log (which was created by the main package).
In order to achieve what you want, you can take the value of the
[MsiLogFileLocation] and store it in a public property, then create a script which will eliminate the log file name from the path ("msilog.txt") then assign the new value to another public property which you can further use in the "Log File:" field in the
"Prerequisites" page -> chained package.
In order to achieve those said above, you can proceed as it follows:
- First we will have to set a public property to have the value of the [MsiLogFIleLocation] property (so we can further use it in our script, because we can only retrieve the values of public properties, meaning that we can not directly retrieve the value of [MsiLogFileLocation] property, since it is a private property). To do so, please go to
"Dialogs" page --> click on
"WelcomeDlg" dialog --> click on the
"Next" button --> under
"Published Events" click on
"New..." to create an event as it follows:
Code: Select all
Event: Set installer property value
Property: MYLOGFILELOCATION (this name can be changed, as per your needs. Just make sure you are using only uppercase characters)
Argument: [MsiLogFileLocation]
Condition: leave unchanged. The default condition is "1" (or "AI_INSTALL")
- Now that we have assigned the value of the [MsiLogFileLocation] to a public property, it is time to create the script which will eliminate the log file name from the full path. To do so, please go to
"Custom Actions" page and add a
"PowerShellScriptInline" custom action
without sequence. To add a custom action without sequence, simply press the
"Add custom action without sequence" button which is place to the right side of the custom action's name. Now, under the "# Your code goes here." comment, please insert the following code:
Code: Select all
$logFile = AI_GetMsiProperty MYLOGFILELOCATION
$logFile = $logFile.Substring(0,$logFile.LastIndexOf('\'))
AI_SetMsiProperty MYNEWLOGFILELOCATION $logFile
Quick Note: The property names are just for the sake of the sample, you can change their names.
Explanation: The first line takes the value of the earlier created property ("[MYLOGFILELOCATION]") and stores it in the "$logFile" variable. The next line eliminates the log file name from the path (e.g. "F:\temp\msilog.txt" becomes "F:\temp"). The last line simply sets a new property to the new value of the "$logFile" variable. This new property will be further used to specify the log file location for your chained packages.
- Now that we have created the script, it is time to trigger it from a dialog control. To do so, please go to
"Dialogs" page --> click on
"WelcomeDlg" --> click on the
"Next" button --> under
"Published Events" tab, click on
"New..." to create an event as it follows:
Code: Select all
Event: Execute custom action
Argument: PowerShellScriptInline
Condition: leave unchanged. The default condition is "1" (or "AI_INSTALL")
- Now the last step is to set the chained package log file location. To do so, please go to
"Prerequisites" page --> click on your chained package --> and you can set the
"Log File:" field as it follows:
Code: Select all
[MYNEWLOGFILELOCATION]\chainLog.txt
Hope this helps.
Also, attached is a sample project for your reference.
All the best,
Catalin