Trying to verify user input in a custom dialog using wix4 (same behavior with rc2, rc3 and latest builds).
I found various examples of how it's supposed to work, but unfortunately I cannot get it right here.
There's a dialog to pick a folder, setting a property like this:
<Publish Dialog="CustomPropertiesDlg" Control="ChangeFooFolder" Property="_BrowseProperty" Value="FOO_DIR" Order="1" />
<Publish Dialog="CustomPropertiesDlg" Control="ChangeFooFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2" />
then I try to run validation when the user clicks Next:
<Publish Dialog="CustomPropertiesDlg" Control="Next" Event="DoAction" Value="UI_CheckFooDir" Order="1" />
<Publish Dialog="CustomPropertiesDlg" Control="Next" Event="NewDialog" Value="InvalidFooPathDlg" Order="2" Condition="FOO_DIR_VALID<>"1"" />
<Publish Dialog="CustomPropertiesDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="5" Condition="FOO_DIR_VALID="1"" />
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="CustomPropertiesDlg" Order="10" />
My expectation at this point is that an invalid directory will set FOO_DIR_VALID
="0" (and "1" if it is).
It's trivial code like this:
[CustomAction]
public static ActionResult VerifyFooPath(Session session)
{
session["FOO_DIR_VALID"] = "0";
var fooDir= session["FOO_DIR"];
session.Log($"Checking whether {fooDir} contains a foo.exe file");
if (Directory.Exists(fooDir) && File.Exists(Path.Combine(fooDir, "foo.exe")))
{
session.Log($"Foo directory accepted as {fooDir}");
session["FOO_DIR_VALID"] = "1";
}
return ActionResult.Success;
}
Yet, even though the log shows me that the custom action executes and sets the FOO_DIR_VALID
property and even though the UI shows me the "Nope, the path is invalid" dialog.. the installation proceeds straight to the server phase afterwards. If I close the dialog (a straight up copy of the default InvalidDirDlg.wxs
with a different message) I want the UI to remain where it is. Let the user fix the error. Yet it skips the VerifyReadyDlg
(the last screen) and immediately prompts for elevation. What am I doing wrong?
Log:
Action start 18:19:30: UI_CheckFooDir.
MSI (c) (F4:04) [18:19:30:414]: Invoking remote custom action. DLL: C:\Users\bla\AppData\Local\Temp\MSI5048.tmp, Entrypoint: VerifyFooPath
MSI (c) (F4:10) [18:19:30:415]: Cloaking enabled.
MSI (c) (F4:10) [18:19:30:415]: Attempting to enable all disabled privileges before calling Install on Server
MSI (c) (F4:10) [18:19:30:415]: Connected to service for CA interface.
MSI (c) (F4!C0) [18:19:30:876]: PROPERTY CHANGE: Adding FOO_DIR_VALID property. Its value is '0'.
Action ended 18:19:30: UI_CheckFooDir. Return value 1.
Action 18:19:30: InvalidFooPathDlg. Dialog created
Action ended 18:19:32: WelcomeDlg. Return value 1.
MSI (c) (F4:34) [18:19:32:623]: Skipping action: MaintenanceWelcomeDlg (condition is false)
MSI (c) (F4:34) [18:19:32:623]: Doing action: ProgressDlg
MSI (c) (F4:34) [18:19:32:623]: Note: 1: 2205 2: 3: ActionText
Action 18:19:32: ProgressDlg.
Action start 18:19:32: ProgressDlg.
Action 18:19:32: ProgressDlg. Dialog created
Action ended 18:19:32: ProgressDlg. Return value 1.
MSI (c) (F4:34) [18:19:32:729]: Doing action: ExecuteAction
MSI (c) (F4:34) [18:19:32:729]: Note: 1: 2205 2: 3: ActionText
Action 18:19:32: ExecuteAction.
Action start 18:19:32: ExecuteAction.
MSI (c) (F4:34) [18:19:32:735]: PROPERTY CHANGE: Adding SECONDSEQUENCE property. Its value is '1'.
MSI (c) (F4:34) [18:19:32:736]: Grabbed execution mutex.
MSI (c) (F4:34) [18:19:32:736]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (c) (F4:34) [18:19:32:736]: Switching to server: (snipped properties here)```
You need to SpawnDialog
the InvalidDirDlg
; NewDialog
replaces the current dialog and InvalidDirDlg
is designed as a popup. (It has only an OK button.)