WiX Multi-instance installer and Installation Directory - wix

I'm trying to get a multi-instance installer working, based on the information in this blog post by #yan-sklyarenko
I'm having trouble understanding how the installation directory should be set when a transform is used. I would like the installer to automatically set it to a directory matching the Product Name, as shown in the examples in the blog post. However, I can't figure out how to do that.
I've tried using the [ProductName] property to dynamically set the name of the install directory, but interpolations do not get expanded in the Name attribute of a Directory.
How should the directory structure be set up in a multi-instance installer?

Related

How to prevent changes in Directories after UISequence

I am linking my product with other libraries, trying to make it easier to install a set of directories in multiple installations. The purpose is to reuse the xml code, problem is they have to be installed in the Root directory per customer requirement.
So I have my ComponentGroups inside the WixLibrary.
I set up my directories in the Wix Application.
But after CostFinalize just before Installation the Directories are reset to their default values and not the ones chosen by my user during the Dialogs Sequence.
Is there a way to prevent this?
Ok, First things first:
The problem is that after CostFinalize and all UI operations my directories where replaced with the default values.
The problem started when I linked two different libraries that used the same global directory.
The folder is set in the root folder of Windows (Per customer Requirement) and then set up to a default value. Then we attach a Property just like we would do it for the WIXUI_INSTALLDIR, overall we have the following:
One root folder for the specific files of the installer
A library that installs files to 4 directories that are unrelated to that root directory.
Another library that installs files and runs scripts to 1 directory of those 4 external directories. This library is the only specifc to our install.
Linking all that is a problem of its own, it has to be done in the Product, in the UI, and using the PropertyRefspecified in the external library. Furthermore, keep in mind that every PathEdit has to be set to Indirect="yes", and you have to set all indirect Properties that point to your Directory in the UI
To fix the problem is really simple, Microsoft Installer rechecks all our folders after the user has set them up during the Install Sequence, so we need to prevent any changes after the user has changed it during the UI Sequence. Thus Properties to the rescue.
Here is an example, in the UI you set a freeze folders to each folder you want to set in the InstallUISequence
<Property Id="SETFOLDERFREEZE">0</Property>
<CustomAction Id="caSetPreventChanges" Property="SETFOLDERFREEZE" Value="1"/>
Then in your Product you link that property.
<PropertyRef Id="SETFOLDERFREEZE"/>
<SetDirectory Id="SPECIFIC_FOLDER" Value="[WindowsVolume]MoreStuff" Sequence="both">
<![CDATA[SETFOLDERFREEZE<>"1"]]>
</SetDirectory>
<Property Id="EXTRAFILES_INSTALLDIR" Value="SPECIFIC_FOLDER"/>
You use the Property EXTRAFILES_INSTALLDIR in your specific UI for that project and you use SPECIFIC_FOLDER in your reusable Library.
It's a mess... but allows reusability, and setting some simple properties and custom actions beats setting up the Files and Folders all over again, specially if there are hundreds of them.

WiX: Copy a file from local folder to installation folder

I'm using a WiX setup project to build an MSI package.
I want the MSI, to do a copy of the given file during the installation to the installation folder from the one, where the .msi file is running from.
I read on WiX a bit, and what I found is the <CopyFile... /> element supposed to do that.
Appreciate your help.
Actually I've figured out what the issue is.
The problem is that the SourceDirectory of the CopyFile element supposed to point to the Directory tag id.
Instead, I've used SourceProperty attribute of the CopyFlie tag, and also defined a Property separately, which made the use of the CopyFile element correct.
So it worked.

How to use WIX CopyFile element to copy file on change/repair to a system folder without installing it to the target?

I have a problem which is related to the execution of CopyFile on change/repair when using WIX to make a msi setup.
I have a feature which has a component which copies/moves a file from the source folder to a folder already present somwhere inside a users system. It is not the folder of my application. I am only moving this file and not installing it to the the target. This feature works fine if I install it using a complete setup. But when on initial install I chose not to install this feature and then try to install it during a " change " all other custom actions/components inside the feature are executed/installed except for the CopyFile component. This is critical to my setup and if it does not get copied my setup will fail.
Just wondering if anyone found a solution to a similar problem or ever came across a similar issue?
The component which contains the CopyFile operation is configured incorrectly. It should have an actual file or registry entry as a key path.
Although Windows Installer uses components to manage resources, the component key path is main factor which decides if the component is installed or not.
So a component without a resource as a key path will never be installed and the CopyFile operation it contains will never be executed.

In WiX, how would you create a dialog to choose the name of a subfolder of the main application directory?

I am developing an MSI installer by using WiX.
The main program installs to [APPLICATIONFOLDER]. I use the InstallDirDlg to set the directory of this without any issues.
I'd like to display a custom dialogue based on the InstallDirDlg to specify a directory to install a particular component. I'd like to set the default directory to [APPLICATIONFOLDER]\Resources. However when I run the installer, I get an error, code 2343.
I think this may be a problem with displaying a second level folder in the dialogue.
You could take a look at how this is done in the WixUI FeatureTree UI example. In particular, look at the CustomizeDlg.
The error 2343 means "Specified path is empty.", so you have probably set a property incorrectly. Looking at the log files generated by your installer may also help.

Using WiX, how to install single file to (potentially) multiple sub-directories, based on what is available at install time?

I'm using WiX, and would like to know the .wxs necessary to take a file and install it to every available sub-directory of a particular location. This could mean 0 or more final installation locations, determined at install time based on the currently existing directory structure. For example, if I started the install with:
\target
\subdir-1
\subdir-2
Then at the end of the installation my file would be in \subdir-1 and \subdir-2. If on the other hand these directories did not exist on the system when the install was started, my file would not be installed at all and no sub directories would be created.
Afaik this is not possible with WiX (because it is basically against the nature of MSI to install a component into several locations).
You could either
create a different component for each subfolder, or
use a custom action to copy the component to all subfolders.
In the latter case you should also provide a corresponding CA for uninstallation which removes all the files from the subfolders again.
EDIT: Seems my above answer is not totally correct. MSI supports duplicating files using the DuplicateFile tables and WiX 3.0 also provides a mechanism called "smart cabbing". Both are mentioned in a blog post by Aaron Stebner.
Not without a custom action, you need to write a custom action that will do that.
The latest and greatest in custom actions is the DTF (and here) framework that comes with Wix3.
If you are targeting Vista (or Win2k8, not sure about Win2k3), you can use mklink.