问题
In WiX installer - How can I customize or override Fatal Error Dialog ()? I would like to show a detailed error message instead of default setup failure message.
Options:
- Is it possible to resize fatal error dialog in WiX?
- If not, how can I use my own dialog in place of fatal error dialog?
回答1:
To resize or otherwise modify any existing dialog in essence you need to replace it. Luckily you can download original sources from git repository and modify them as you like.
Firstly to be able to modify any UI element you need to override the default UI table. Lets modify InstallDir UI for this example:
<UIRef Id="WixUI_InstallDir" /> <!-- original -->
<UIRef Id="CustomWixUI_InstallDir" /> <!-- modified -->
Now lets modify WixUI_InstallDir by downlaoading the source and changing what we want. We do that by adding a new CustomWixUI_InstallDir.wxs file to the setup. The contents can be downloaded from WixUI_InstallDir.wxs git.
Assign a unique ID for this UI by changing Id attribute of element UI inside the newly created CustomWixUI_InstallDir.wxs file:
<UI Id="WixUI_InstallDir"> <!-- original -->
<UI Id="CustomWixUI_InstallDir"> <!-- modified -->
Find a line that references the FatalError dialog and replace it with your own fatal error dialog like so:
<DialogRef Id="FatalError" /> <!-- original -->
<DialogRef Id="Custom_FatalError" /> <!-- modified -->
Now we need to download FatalError.wxs source once again or create it from scratch. Lets download the FatalError.wxs source from git once again. And add it as a new setup file named Custom_FatalError.wxs.
There still is a step to make this dialog appear after a fatal error during the setup: Find the lines in the Custom_FatalError.wxs file, that sequence this dialog and replace them with your own dialog id like so:
Original:
<InstallUISequence>
<Show Dialog="FatalError" OnExit="error" Overridable="yes" />
</InstallUISequence>
<AdminUISequence>
<Show Dialog="FatalError" OnExit="error" Overridable="yes" />
</AdminUISequence>
Modified:
<InstallUISequence>
<Show Dialog="Custom_FatalError" OnExit="error" /> <!-- note that Overridable attribute is removed -->
</InstallUISequence>
<AdminUISequence>
<Show Dialog="Custom_FatalError" OnExit="error" />
</AdminUISequence>
This is it now you can freely modify the FatalError dialog or any other dialog by following this example. I personally added a custom error message in a FatalError dialog by modifying a Description control:
<Control Id="Description" Type="Text" X="135" Y="70" Width="220" Height="80" Transparent="yes" NoPrefix="yes" Text="!(loc.FatalErrorDescription1) [CUSTOMERRORMESSAGE] !(loc.FatalErrorDescription2)" />
来源:https://stackoverflow.com/questions/39909870/wix-installer-resize-fatal-error-dialog-or-use-custom-dialog-in-place-of-fatal