Windows Installer installs to Defaultlocation even when a different directory is selected
I hope this hasn't already been answered, but I feel like I have read every related article on the entire internet...
I need to have the DefaultLocation property of the Installer default to C:\ or D:\ (ideally there would be logic here but I have already learned that can't be done because Custom Actions are executed after the files are installed).
The issues I am seeing is that if I use the property for [TARGETDIR] or [ROOTDRIVE] which generally defaults to C:\ or D:\, that if a user selects a different install location, the installer ignores the location t开发者_高级运维hey selected.
For example on my machine [ROOTDRIVE] resolves to C:. If I tell the installer to D:\, it installs to C:\ anyway. This happens with both the [TARGETDIR] and the [ROOTDRIVE] property.
Has anyone seen this or know why this is happening?
Thanks, Steve
You don't want to be setting TARGETDIR
as this defaults to the drive with the largest amount of free space, generally you'd use something like INSTALLDIR
or APPLICATIONFOLDER
and have the user customize that property instead. The WiX sample below defaults to C:\Program Files\ACME Xyz\My Program
but if the user changes the location of APPLICATIONFOLDER
to say D:\blahblahblah
then the files will be installed there.
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="MyCo" Name="ACME Xyz">
<Directory Id="APPLICATIONFOLDER" Name="My Program" DiskId="1">
</Directory>
</Directory>
</Directory>
</Directory>
EDIT:: In that case, just use an immediate custom action. e.g.
<CustomAction Id="SetInstallFolder" Property="APPLICATIONFOLDER" Value="D:\" Execute="immediate" />
<InstallExecuteSequence>
<Custom Action="SetInstallFolder" Before="CostFinalize">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
</InstallExecuteSequence>
<InstallUISequence>
<Custom Action="SetInstallFolder" Before="CostFinalize">ACTION="INSTALL" AND APPLICATIONFOLDER="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
</InstallUISequence>
I just figured out WHY this was happening with the Visual Studio installer and more importantly how to rectify it.
There is a property called "PackageAs", which can be accessed within Visual Studio on each file that is used in the setup file. By default this property is set to "vsdpaDefault" which based on the little bit of information I was able to uncover causes the file to be compressed, which in turn changes the file and subsequently the LastModifiedDate.
This can be resolved by changing the file you wish to maintain the LastModifiedDate on to PackageAs "vsdpaLoose". This causes the file to NOT be compressed and maintain its properties.
Hopefully someone else will have the same issue and find this useful.
精彩评论