Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
547 views
in Technique[技术] by (71.8m points)

wix - Windows Installer evaluates ROOTDRIVE to local drive with less free memory space => why?

Lots of pages in the internet and books about Windows Installer are citing the following Microsoft page ROOTDRIVE for:

If ROOTDRIVE is not set at a command line or authored into the Property table, the installer sets this property. During an administrative installation the installer sets ROOTDRIVE to the first connected network drive it finds that can be written to. If it is not an administrative installation, or if the installer can find no network drives, the installer sets ROOTDRIVE to the local drive that can be written to having the most free space.

Well, on my customer's machine C: has lots of more free space than Y:, but the application gets installed into Y:MyApp instead of C:Program Files (x86)MyApp. Of course the WiX and Directory structure are standard-style:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="$(var.CompanyName)">
      <Directory Id="MyAppFolder" Name="MyApp" />
    </Directory>
  </Directory>
</Directory>

So nothing special. On other machines it installs to Program Files folder as expected.

From my daily experience the rule with the "most free space" cannot be true, since on lots of machines I am dealing with have a rather small SSD as C: local drive and a much, much more bigger data drive D: with Terabytes more free space than C:. If that rule would fit then nowadays most of the computers would have (all) their applications being installed to their Data Drive root directory (e.g. D:) and not underneath the specially-protected %ProgramFiles%/%ProgramFiles (x86)% folders. On all my machines with the configuration small SSD vs. big data HDD with more space all the stuff gets installed into my expected Program Files folders in C:. So the rule of the "most free space" is definitely NOT TRUE!!! And the MSIs are not especially defining any TARGETDIR or ROOTDIR property to C: on command line neither MSI table in any case!

So there must be another evalution rule. Which one is it? Who can explain the odd behaviour?

EDIT

Thanks to Stein I did a closer look at the logs and found out that ROOTDRIVE actually really points to the larger local disks but due to the higher priority of the System Folder Properties it always gets installed into the right place on System Drive. The log file I also looked into when asking the question was the one from Dell Data Protection which explicitly must have set ROOTDRIVE to C: or System Drive. Thus The ROOTDRIVE rule from MSDN seems to be true but it does not have any effect in most of the times.

When I looked on the problem computer myself I saw that Y: was a network drive, then I searched for the word ADMIN et voilà: it was an administrative installation although my customer told me that he just double-clicked on the MSI and Y: was a local drive => my airing grievance this year for the festivus will be that one should not never believe what the customer says and vows ;-)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

System Folder Properties: I think the answer can be found in this Symantec Article. Essentially: System Folder Properties are not affected by the ROOTDRIVE property.

Incidentally my D: drive has more space than my C: drive and ROOTDRIVE is set to D: in the MSI log file. Installation writes no files to D: though. I would think this is due to ample space on C:?


UPDATE: Also check the documentation on TARGETDIR, with focus on this section:

"...if the TARGETDIR property is defined, the destination directory is resolved to the property's value. If the TARGETDIR property is undefined, the ROOTDRIVE property is used to resolve the path."


Problem Computer: The above does not really explain what happens on your problem computer, does it? Did you ever install manually to this custom location? Did you use a "Remember Property" pattern to persist the installation folder? It must be reading back that old path? Or maybe the disk is very low on space? Or are you installing using an admin image? AdminProperties. No Set Property custom actions in there? Could there be constructs in the GUI that could affect this? I know set property is used in some of WiX's default GUI sets. And you can make directories modifiable as "feature directories". See the screenshot down the page here.

Verbose Log: I would suggest you make a log file on a system where the installs go to a secondary drive and check what is written into the log with regards to ROOTDRIVE and directory resolution in general. In corporate environments where target computers are uniform many actually hard code ROOTDRIVE to C: - not great, but they do. They wouldn't do that unless they are trying to avoid some random side effect along the lines of what you describe.

Festivus Grievance: I have always disliked this ROOTDRIVE issue, and never fully understood it to be honest. I hear you in other words. It is in fact one of my Festivus grievances against MSI. Did I answer? Not really :-). You have some pointers at least. Maybe the WiX guys, Chris Painter or PhilDW can provide a complete answer.


Do Not Use the below construct:

<!--ROOTDRIVE explicitly set to prevent it from defaulting to drive with most space-->
<Property Id="ROOTDRIVE" Value="$(env.SystemDrive)" />

<!-- NO SOLUTION -->

The above will be a compile time resolution, and not a runtime resolution of the folder. In other words it is no solution at all. ROOTDRIVE will be set to the system drive letter of the build computer, not of the computer you install to.

Construct you can try to force ROOTDRIVE to be set to the system drive:

<CustomAction Id='SetRootDrive' Property='ROOTDRIVE' Value='[%SystemDrive]' />

<InstallUISequence>
  <Custom Action="SetRootDrive" Before="CostInitialize"></Custom>
</InstallUISequence>

Some Links:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...