WIX installer: Use property value to place a file - wix

I've read a property from the registry, and that property has been set properly (I'm using this to check the property value)
<CustomAction Id="Test" Script="vbscript">
<![CDATA[MsgBox Session.Property("MYEXTRAFILESFOLDER")]]>
</CustomAction>
Now I'm just trying to drop a few files into that folder. I can't figure out how to make a File element target a specific directory.

As I get you don't need to change taget path in general but only put some files to specific folder. Easiest way is to create custom action.
Add custom action as described
In InstallExecuteSequence set After=InstallFiles or After=InstallFinalize (to make sure that your files from installer will be copied already)
In custom action read you path from registry
Get you install path using TARGETDIR
Move files from TargetDir to your registry dir
Another option is
Create custom action as described
In custom action read you path from registry
Get file stream from installer and write it to folder
Also this can be an option too. But I don't know how it works exactly

Related

WiX CopyFile with external file doesnt execute in change mode

In my setup i copy an external file (which path comes from an custom action) into the install directory with CopyFile. This works for an clean new installation.
But when the user chooses "change installation" on second execution of the setup and choose an different external file, the CopyFile isn't executed and the file doesnt get updated.
This is the component with CopyFile. In CFGFILE is the path to the file the users has chosen stored.
<Component Id="C_CopyCfgFile" Guid="0D09480A-36E8-41C9-B887-0C6AF0B99E05">
<Condition><![CDATA[CFGFILE <> ""]]></Condition>
<CopyFile Id="copyCFG" DestinationDirectory="INSTALLDIR" SourceProperty="CFGFILE" DestinationName="prod_556.cfg" />
</Component>
It seems that the installer doesnt recognize the change of the CFGFILE property. What must be done to, that the file is copied every time?
Edit:
In the log file the folllowig appears at change install:
MSI (s) (4C:38) [08:36:30:724]: PROPERTY CHANGE: Modifying CFGFILE property. Its current value is 'C:\Users\marco\Desktop\newconfig.cfg'. Its new value: 'C:\Users\marco\Desktop\newconfig.cfg\'.
That is the new file that is choosen at "change" install. The original file is never mentioned in the log
A verbose log file will tell for sure, but the Component install state is probably detected as already present since the KeyPath of the Component is just it's Directory.
So, you'll need to manually set the parent Feature of the Component install state to be reinstalled. See the REINSTALL Property.

Accessing directory property in Custom Action Wix

I have a WIX installation I am attempting to run, which has a custom action which creates some .INI files based on user input, and is supposed to put them in a subfolder of the user's chosen installation folder. I am attempting to pass the WIXUI_INSTALLDIR property to the C# Custom Action file, but this just passes its value of INSTALLFOLDER, instead of INSTALLFOLDER's Path. Does anyone have advice on how to do this?

Howto create Directory in Temp Install Dir for Custom Action

I've got an C# Wix Custom Action which is reponsible for setting up Datatabase.
All needed Dlls are extracted during Installation into C:\windows\installer\currentinstalldir.
So thats fine. The needed Sql Files are in the same Directory, but they have to be copied to
C:\windows\installer\currentinstalldir\sqlscripts.
I've found a way to get what i want.
This code used as PostBuild Function does what i need.
%wix%SDK\MakeSfxCA.exe “$(TargetDir)$(TargetName).CA$(TargetExt)” “%wix%SDK\x86\SfxCA.dll” “$(TargetPath)” “$(TargetDir)Microsoft.Deployment.WindowsInstaller.dll”
Found on buildmaestro
But due to a limitation of cmd.exe (max Chars) I could not add all files I need.
My Workarround ist to Install these Files as a hidden feature and pass the Directory via Install Property to my Custom Action.

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.

Sequencing issue when reading an ini file with Wix

I have to read an ini file with Wix. This ini file is created by the installer itself by a custom action (an exe file generates the ini file).
Problem:AppSearch (where the ini file is read) is the first step of the InstallUISequence.
Even if I call the CA before AppSearch, I get an error because when I try to read the ini file, it is not created yet..(Return="asyncWait" in the CA).
Here is the call:
<InstallUISequence>
<Custom Action="LaunchCA" Before="AppSearch" />
</InstallUISequence>
Is there a solution? Thanks!
Windows Installer INI searches support only files in C:\Windows folder. So using a search is not feasible.
Instead, you can try using a custom action (custom code written by you) to read the file. I assume you want to save the result in some installer properties. So your custom action will need to receive the installation handle.
So, what you need is to access the data in that generated INI file, right? Do you control the way that EXE outputs the data?
If you do, you can make that data to be dumped not to INI file, but to the custom MSI table instead. Later on, your CA to read the contents of the INI file doesn't have to wait for it to gets created and you'll get rid of the AppSearch dependency.