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.
Related
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
How to use FileSearch result as condition in Component section.
I want to get something like this:
<Property Id=\"CONFIG_XML_EXISTS\">
<DirectorySearch Id="CheckForConfigXml" Path="[INSTALLDIR]\">'
<FileSearch Id="ConfigXmlSearch" Name="config.xml" />
</DirectorySearch>
</Property>
...
<Component Id="c_DefaultConfig.xml" Guid="{1AAB0AFD-B763-4A55-8585-B0AD4D8CE23C}">
<File Id="f_default_config.xml"
Name="default-config.xml"
Source="$(var.SourceRoot)\config.xml"/>
<Condition>CONFIG_XML_EXISTS</Condition>
</Component>
I don't know why but property wix doesn't want to evaluate CONFIG_XML_EXISTS.
Because that search happens very early in the install, the most likely reason is that INSTALLDIR has no value. You haven't said whether you're doing a fresh install or an upgrade, so it's not clear where you think it might be getting its value from.
I'd also point out that the purpose of that source code is apparently to prevent the install of a file if there is one there already, so:
If INSTALLDIR turns out to be the application folder (typically program files) where your files are installed then users can usually change this location, so it's not clear the file is going to be where you expect it to be.
The file overwrite rules prevent incoming files from overwriting modified data files (modify date > creation date) so if that config file has been changed it won't be overwritten and you don't need to do the check.
In your comment you say "My installer must create file config.xml only if there is no such file in target(install) directory. If such file exists, my installer must create file with name template.xml". I think that perhaps the easiest way to do this is in the application after the install has finished, or possibly in a custom action after all the files have been installed. There seems to be no good way to do this before the install because INSTALLDIR is unpredictable. I've seen this kind of problem solved by installing the XML files to (say) User's Application Data, and after the files are installed then the application or a custom action can see what files are there (or not) and get them from User's Application Data.
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.
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.
I have multiple config files (for different environments). During install user get to select the environment, and based on that correct files are copied. I want to delete the extra files that are not used.
I am using but it doesn't seem to be working. I don't get any errors as such, in the log I see action getting executed but files are not deleted. Can anyone please point what I am doing wrong?
<Component Id="RemoveFiles" Guid="C5D634C2-744E-4CA5-BB44-F3DE88482AB5">
<RemoveFile Id="RemoveConfigs" Name="???_*.config" On="install" />
</Component>
My RemoveFile table also looks like
FileKey Component FileName DirProperty InstallMode
RemoveExtraConfigFiles RemoveExtraFiles p6wjlh9a.con|Web_*.config INSTALLDIR 1
Still it's not deleting anything
RemoveFile or CopyFile always run before InstallFiles, and it finds no files in the install directory, hence it fails.
The RemoveFiles action will try to find the files you specified in the parent directory of the component, in case you don't override it in the RemoveFile element itself (according to your sample, you don't). Make sure that it is really a folder containing that file. If the file is not found, the action won't fail - it will silently continue.