79351867

Date: 2025-01-13 10:34:24
Score: 3
Natty:
Report link

I have also faced this issue and been trying to recreate the official docu use case for many hours, and finally found a solution.

Keep in mind that I'm also a beginner to Wix, so if anyone has any improvements feel free to add.

1- You need to download or copy the WixUI_InstallDir.wxs file from the official github repository into your project file.

2- Then you need to change the ids of the UIs in the file:

<UI Id="WixUI_InstallDir_Custom_$(WIXUIARCH)">
...
<UI Id="WixUI_InstallDir_Custom_ExtendedPathValidation_$(WIXUIARCH)">
...
<UI Id="file WixUI_InstallDir_Custom">

Also change the Id in the package file:

<ui:WixUI Id='WixUI_InstallDir_Custom' InstallDirectory='INSTALLFOLDER'/>

3- If you try to build your project now, you may face an error saying: The identifier 'WixUI:WixUI_InstallDir' is inaccessible due to its protection level. and pointing to the first UIRef in the file. You just need to also change it to the new custom name:

<UIRef Id="WixUI_InstallDir_Custom" />

I'm not sure why it only points to the first reference.

4- Now if you try to build you'll face the same error you mentioned above: The primary key 'BrowseDlg/OK/SetTargetPath/[_BrowseProperty]/1' is duplicated in table 'ControlEvent'. Please remove one of the entries or rename a part of the primary key to avoid the collision.
To Fix this, You just need to comment out the publish statements related to _BrowseProperty in the WixUI_InstallDir_Custom UI.

5- You will then face the same error but this time pointing to the EndDialog event for the BrowseDlg. Like before just comment out the publish statement related to it.

<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg" />
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="3" />
<!--<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1" />-->
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2" />

<!--<Publish Dialog="BrowseDlg" Control="OK" Event="SetTargetPath" Value="[_BrowseProperty]" Order="3" />-->
<!--<Publish Dialog="BrowseDlg" Control="OK" Event="EndDialog" Value="Return" Order="4" />-->

6- Now you will face another error related to the license page, but since you and I don't need it, we can just remove it just like in the offical docu, and edit the next and back attributes for the WelcomeDlg and InstallDirDlg:

<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Condition="NOT Installed" />
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" />

7- You can now build it and the license page is no more. You can also now add your custom dialog with no issues, put its Id in the next and back attributes in the same way as the official docu.

This is how my WixUI_InstallDir.wxs file looked by the end:

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<?foreach WIXUIARCH in X86;X64;A64 ?>
<Fragment>
    <UI Id="WixUI_InstallDir_Custom_$(WIXUIARCH)">
        <Publish Dialog="BrowseDlg" Control="OK" Event="CheckTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1" />

        <Publish Dialog="InstallDirDlg" Control="Next" Event="CheckTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1" />
        <Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4" />
    </UI>

    <UIRef Id="WixUI_InstallDir_Custom" />
</Fragment>
<?endforeach?>

<?foreach WIXUIARCH in X86;X64;A64 ?>
<Fragment>
    <UI Id="WixUI_InstallDir_Custom_ExtendedPathValidation_$(WIXUIARCH)">
        <Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath_$(WIXUIARCH)" Order="1" />
        <Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="2" Condition="WIXUI_INSTALLDIR_VALID&lt;&gt;&quot;1&quot;" />

        <Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath_$(WIXUIARCH)" Order="1" />
        <Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="2" Condition="WIXUI_INSTALLDIR_VALID&lt;&gt;&quot;1&quot;" />
        <Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4" Condition="WIXUI_INSTALLDIR_VALID=&quot;1&quot;" />
    </UI>

    <UIRef Id="WixUI_InstallDir" />
</Fragment>
<?endforeach?>

<Fragment>
    <UI Id="file WixUI_InstallDir_Custom">
        <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
        <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
        <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

        <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />

        <DialogRef Id="BrowseDlg" />
        <DialogRef Id="DiskCostDlg" />
        <DialogRef Id="ErrorDlg" />
        <DialogRef Id="FatalError" />
        <DialogRef Id="FilesInUse" />
        <DialogRef Id="MsiRMFilesInUse" />
        <DialogRef Id="PrepareDlg" />
        <DialogRef Id="ProgressDlg" />
        <DialogRef Id="ResumeDlg" />
        <DialogRef Id="UserExit" />

        <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999" />

        <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Condition="NOT Installed" />
        <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Condition="Installed AND PATCH" />


        <Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" />
        <Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="3" />
        <!--<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1" />-->
        <Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2" />

        <!--<Publish Dialog="BrowseDlg" Control="OK" Event="SetTargetPath" Value="[_BrowseProperty]" Order="3" />-->
        <!--<Publish Dialog="BrowseDlg" Control="OK" Event="EndDialog" Value="Return" Order="4" />-->

        <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1" Condition="NOT Installed" />
        <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2" Condition="Installed AND NOT PATCH" />
        <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2" Condition="Installed AND PATCH" />

        <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg" />

        <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg" />
        <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg" />
        <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg" />

        <Property Id="ARPNOMODIFY" Value="1" />
    </UI>

    <UIRef Id="WixUI_Common" />
</Fragment>

and my package file only has the simple reference:

<ui:WixUI Id='WixUI_InstallDir_Custom' InstallDirectory='INSTALLFOLDER'/>
Reasons:
  • Blacklisted phrase (1): to comment
  • Long answer (-1):
  • Has code block (-0.5):
  • Me too answer (2.5): face the same error
  • Low reputation (1):
Posted by: Solsen165