How can I enable logging in my wix project and set MsiLogFileLocation? Now I am running my install.msi with command line arguments:
msiexec /i install.msi /l*v InstallLog.log
I want to log my work always just running install.msi without any arguments. Are there any way to do that?
Setup tab > Run after execution input: your msi file name. Advanced tab > Mark Request Administrative access option checkbox.
Under Group Policy, expand Computer Configuration, expand Administrative Templates, expand Windows Components, and then select Windows Installer. Double-click Logging, and then click Enabled. In the Logging box, enter the options you want to log. The log file, Msi.
Break() function under “ System. Diagnostics ” namespace. That way when running the MSI, a popup will be presented asking if you want to “Debug the program”. Click on this option and then choose the Visual Studio instance on which the custom action project is open on.
You can tell WiX to use verbose logging like this:
<Property Id="MsiLogging" Value="v" />
but you can't specify where to write the file - msiexec has already determined that by the time WiX gets to set the property. It'll default to %TEMP%\MSI{random chars}.LOG
. You could offer the user a checkbox to determine if they want to open that log, like this (assuming you're using the built in InstallDir UI template - it'd be possible with others as well, but this is a pretty simple example):
<Property Id="MsiLogging" Value="v" />
<UI>
<UIRef Id="WixUI_InstallDir" />
<Publish Dialog="ExitDialog"
Control="Finish"
Event="DoAction"
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="View Installation Log" />
<WixVariable Id="WixUILicenseRtf" Value="license.rtf"/>
<Property Id="WixShellExecTarget" Value="[MsiLogFileLocation]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
This would copy the log file to a directory about as late as possible in the game, but would miss at least some of the tail end of the log:
<Property Id="MsiLogging" Value="v!" />
<CustomAction Id="CopyLog" Execute="immediate"
ExeCommand="cmd /c copy [MsiLogFileLocation] C:\temp\log.txt"
Directory="TARGETDIR"
Impersonate="no"
Return="asyncNoWait" />
<InstallExecuteSequence>
<Custom Action="CopyLog" OnExit="success" />
</InstallExecuteSequence>
Note that this won't work for the C:
drive root, because that requires administrative privileges. If you're ok missing even more of the log, you could change OnExit='success'
to After='InstallFinalize'
and change the Execute
attribute on the CustomAction
to commit
. That should allow it run as administrator.
See this discussion for a bit more: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Setting-MsiLogFileLocation-property-td7374335.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With