[wix-users] WIX - MSI: how to create/append the Application folder name at the end of the Target/installation path

mallikarjun reddy gmgm.cool at gmail.com
Thu Jul 30 04:02:48 PDT 2015


I want to create/append the Application folder name at the end of the
Target/installation path.

The default path is "C:\CompanyName\" In this case also it should install
in "C:\CompanyName\AppName"

And if the user changes the path to "C:\Test\" (by browse dialog or by
typing in the text box), then installation should happen in the
"C:\Test\AppName"

I've referred the Wix UI as "WixUI_InstallDir"

I've also Set the Property Id="WIXUI_INSTALLDIR" Value="APPPATH".

And my all shortcuts should point to the final installation path.

Sample snippet code:

Product.wxs

<?xml version='1.0' encoding='windows-1252'?>
 <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
    <!--- some code here --->
    <Property Id="APPPATH" Secure="yes"><![CDATA[C:\CompanyName]]></Property>
    <Property Id="WIXUI_INSTALLDIR" Value="APPPATH" />
    <Property Id="ALLUSERS">1</Property>
<!--- some code here --->
    <Directory Id='TARGETDIR' Name='SourceDir'>
        <Directory Id='ProgramFilesFolder' Name='PFiles'>
            <Directory Id='APPPATH' Name='Product_Title'>
                  <Directory Id='ConfigurationId' Name='Configuration'>
            <!--- some code here --->
                    </Directory>
                 </Directory>
            </Directory>
        </Directory>

        <!--- some code here --->
     <UI Id="CustomWixUI_Mondo">
              <UIRef Id= "AppWixUI_InstallDir" />
              <UIRef Id="WixUI_ErrorProgressText" />
    </UI>

</Product>

AppWixUI_InstallDir.wxs

<?xml version="1.0" encoding="UTF-8"?>
 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <UI Id="AppWixUI_InstallDir">

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

        <DialogRef Id="BrowseDlg" />
        <!-- some more code... .... -->

        <Publish Dialog="BrowseDlg" Control="OK" Event="DoAction"
Value="WixUIValidatePath" Order="3">1</Publish>
        <Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog"
Value="InvalidDirDlg"
Order="4"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>



        <Publish Dialog="AppInstallDirDlg" Control="InstallNoShield"
Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
        <Publish Dialog="AppInstallDirDlg" Control="InstallNoShield"
Event="DoAction" Value="WixUIValidatePath" Order="2">NOT
WIXUI_DONTVALIDATEPATH</Publish>
        <Publish Dialog="AppInstallDirDlg" Control="InstallNoShield"
Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT
WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
        <Publish Dialog="AppInstallDirDlg" Control="ChangeFolder"
Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]"
Order="1">1</Publish>
        <Publish Dialog="AppInstallDirDlg" Control="ChangeFolder"
Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>

        <!-- some more code... .... -->

    </UI>

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

AppInstallDirDlg.wxs

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
 <Fragment>
    <UI>
        <Dialog Id="AppInstallDirDlg" Width="370" NoMinimize = "yes"
Height="270" Title="InstallDirDlg_Title">


            <Control Id="InstallNoShield" Type="PushButton"
ToolTip="Next" ElevationShield="no" X="4" Y="243" Width="80"
Height="17" Default="yes" Hidden="yes" Disabled="yes" Text="Next">
                <Condition Action="show">NOT Installed </Condition>
                <Condition Action="enable">NOT Installed</Condition>

                <Condition Action="default">NOT Installed</Condition>
                <Publish Event="EndDialog"
Value="Return"><![CDATA[OutOfDiskSpace <> 1]]></Publish>
                <Publish Event="SpawnDialog"
Value="OutOfRbDiskDlg">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0
AND (PROMPTROLLBACKCOST="P" OR NOT PROMPTROLLBACKCOST)</Publish>
                <Publish Event="EndDialog"
Value="Return">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND
PROMPTROLLBACKCOST="D"</Publish>
                <Publish Event="EnableRollback"
Value="False">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND
PROMPTROLLBACKCOST="D"</Publish>
                <Publish Event="SpawnDialog"
Value="OutOfDiskDlg">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1)
OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST="F")</Publish>
            </Control>

            <!-- <Control Id="Next" Type="PushButton" X="4" Y="243"
Width="56" Height="17" ToolTip="Next" Default="yes" Text="Next" /> -->
            <Control Id="Back" Type="PushButton" X="246" Y="243"
Width="56" Height="17" ToolTip="Back" Text="Back" >
                <Publish Event="NewDialog"
Value="AppLicenseAgreementDlg">1</Publish>
            </Control>
            <Control Id="Cancel" Type="PushButton" X="304" Y="243"
Width="56" Height="17" ToolTip="Cancel" Cancel="yes" Text="Cancel">
                <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
            </Control>

            <Control Id="FolderLabel" Type="Text" X="20" Y="58"
Width="290" Height="15" NoPrefix="yes" Text="InstallDirDlgFolderLabel"
/>
            <Control Id="Folder" Type="PathEdit" X="20" Y="75"
Width="320" Height="18" Property="WIXUI_INSTALLDIR" Indirect="yes" />
            <Control Id="ChangeFolder" Type="PushButton" X="20" Y="96"
Width="80" Height="17" ToolTip="Change Folder"
Text="InstallDirDlgChange" />
            <Control Id="DiskUsage" Type="Text" X="20" Y="128"
Width="290" Height="15" NoPrefix="yes" Text="InstallDirDlgDiskUsage"
/>
            <Control Id="VolumeList" Type="VolumeCostList" X="20"
Y="145" Width="320" Height="75" Sunken="yes" Fixed="yes" Remote="yes"
Text="DiskCostDlgVolumeList" />
        </Dialog>
      </UI>
   </Fragment></Wix>



-- 
Regards,
Mallikarjun.
keep smiling...


More information about the wix-users mailing list