Directories are in a hierarchy, starting with TARGETDIR. In CostFinalize,
they actual paths to the directories are set (and become Properties with the
same name if the property didn't already exist). Here is how they are built:

When CostFinalize runs, if a property with the same "Id" (to use WiX terms)
exists as the directory being parsed, that property's value become the path
to the directory (the path to the parent AND the "Name" value are ignored).
That is why setting the property INSTALLDIR to "Acme" didn't work.
Otherwise, the "Name" (followed by a \ char) is added to the parent's path
(if no Name is supplied, it is ".").
The result is canonicallized [I think I spelled this wrong...] and a
property with the same Id is then created. (thus C:\Program
Files\.\.\Acme\.\.\en-us\ becomes C:\Program Files\Acme\en-us\).

Because of that if you set a property before CostFinalize to establish a
directory it must always be an absolute path.

You can use a SetDirectory action after CostFinalize to change paths
after-the-fact, but I won't go into that here. It should be straight-forward
(except for all the side effects, limitations, etc.)

In your example UI code, you tell the InstallDirDlg to set the property
named " INSTALLDIR " while the directory you want to change is called
"INSTALLDIR". That appears to me to be the bug in your code.

-----Original Message-----
From: Nicholas Makin [mailto:nma...@opentext.com] 
Sent: Thursday, September 03, 2009 10:12 AM
To: General discussion for Windows Installer XML toolset.
Subject: [WiX-users] Allowing the user to override the install directory

Please excuse my frustration but I am finding WiX to be neigh worthless -
why? Because there is a plethora of information by half of it is no good and
the other half points you to the mysterious MSI documentation which is
wonderful if one could figure out how that translates to WiX.

All I want to do is have a default directory structure:

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder" Name="PFiles">
        <Directory Id="INSTALLDIR" Name="Acme">
            <Component Id="AppSettings" Guid="
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ">

But let the user choose to install in another place:

          <Property Id="WIXUI_INSTALLDIR" Value=" INSTALLDIR " />
          <Publish Dialog="InstallDirDlg" Control="Next"
Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
          <Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog"
Value="VerifyReadyDlg" Order="2">1</Publish>
          <Publish Dialog="InstallDirDlg" Control="ChangeFolder"
Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
          <Publish Dialog="InstallDirDlg" Control="ChangeFolder"
Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>

However when I use the above - no matter what the user chooses the component
is always placed at: C:\Program Files\Acme - i.e. the dialog is pointless.

So I made this change:

<Property Id="INSTALLDIR" Value="Acme" />
<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder" Name="PFiles">
        <Directory Id="INSTALLDIR" Name=".">
            <Directory Id="FILELOC" Name="OTInstaller">
                <Component Id="AppSettings" Guid="
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ">

Well this tries to install to come network drive named Acme.

I did find that I can insert "C:\Program Files\Acme" but this results in a
warning about hard coding directories This is what I guess I will have to
live with. I did try something like [ProgramFilesFolder]\Acme - but this too
resulted in an error - I guess a property can't be used to set another
property in this way.

Ultimately I know that my frustrations are a result of just not
understanding how MSI works with directories but all I have are 100's of
examples to extrapolate from and none of them seem to offer correct advice
(i.e. it either does not work (WiX Wiki example) or results in errors). As I
fight my way though building this installer I find that this has
consistently been the case - 100's of examples but no real information to
help you extrapolate to achieve what you need which is often just a tiny
tweak on the example. Without some sort of understanding there is no way to
get form the example to the desired functionality - and how can you build
understanding from examples that don't work?

So aside from helping me get these files placed where the user wants them -
if someone ever figure out the secret to WiX - write a good solid book on it
and I will buy it and I know other users will love to have it. WiX is
wonderful - but so much time gets wasted trying to work out details. I am
ever to tempted to use VBScript to do custom actions to do things that WiX
clearly can do - just because I cannot figure out HOW to do it. This is
madness

(I have found many books with WiX examples - generally a 2-3 page section
with an example that is usually copied from the tutorial (or darn near) or
the Wiki.)

Nicholas

(again sorry for the frustration in my tone)
----------------------------------------------------------------------------
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus
on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to