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.
Related
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.
with the Wix Toolset v3.11 I have created a .msi file for my application (let's say version 1.1) with a Directory element that targets the LocalAppDataFolder and puts a Temp folder underneath. This structure is used with a DirectoryRef element to put some files there that are accessed within a custom action on InstallFinalize. Now I generated a Patch (version 1.2) that adds some files in the Temp folder. But I want that folder to be in the TARGETDIR now. So I changed
<Directory Id="LocalAppDataFolder">
<Directory Id="APPDATA_TEMP" Name="Temp" />
</Directory>
to
<Directory Id="MY_TEMP_PATH" Name=".">
<Directory Id="APPDATA_TEMP" Name="Temp" />
</Directory>
underneath the
<Directory Id="TARGETDIR" Name="SourceDir">
structure. For the Patch to be applied correctly I opened the .msi file that's referenced in the registry (under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\...\Products{GUID}\InstallProperties\LocalPackage) with the Orca tool and edited the corresponding values in the Directory table. I also edited the CustomActions table to reference the new path as it is used as a parameter there. So, now when I install the Patch it puts all the files (changed and new ones) in the LocalAppDataFolder as it did with the initial install. The custom action is called with the correct parameter though.
Is there a way to change the "base" msi to target my new Temp folder or, alternatively, somehow tell the Patch to use the new folder regardless of the initial path?
The goal is to apply the patch without having to uninstall the application first.
Any help on how to achieve that is greatly appreciated.
Finally we found a solution. So here's what solved our problem, should anyone ever come across something similar:
We found the actual path of the LocalAppDataFolder in two locations in the registry: The first entry is located in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders. The second one is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData...\Components. The entry with the component ID that puts the files in the Temp folder holds exactly one value, which is the path to the first file in that component. We changed both paths to our new temp folder.
Now the patch extracts the files correctly to the new temp folder and the custom action can process them further.
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've a problem with reinstallation, where doesn't exists a subfolder, what was in version before. In version 1 there in some wxs file exists:
<Component Id="cmp7EB6415256FC5DA344472986974956E4" Directory="dir74C41F8B6B03DD308C9CCD0008B2F7E5" Guid="{9BD5E948-E8EA-4C5E-B5F4-7002B28765D9}" KeyPath="yes" MultiInstance="yes">
<CreateFolder />
</Component>
In version 2 it doesn't exists. During reinstallation there is no phase copy files and original files remaininig, but there is no error at the end. When I remove the component new files are copied.
The wxs file is created by heat. I have a quite huge number of folders and subfolders, and the project is dynamic. It means that everybody can add or remove a folder and I cannot check if somebody deleted any of them.
The Windows Installer only creates Directories that are required to install Files or that are explicitly called out by a CreateFolder element. You'll need to add a CreateFolder somewhere to get the empty Directories to remain.