I had a problem using deferred CustomAction, where the parameter is passed as a link to a file identifier in the style of [# file.Product.exe.config]:
<Component Id="comp.Product.exe.config" Guid="{966DA007-E3F0-4BFE-94ED-63A66F82CA58}" Win64="$(var.Win64)"> <File Id="file.Product.exe.config" Name="Product.exe.config" Source="$(var.SourcePath)\Product.exe.config" KeyPath="yes" /> </Component>
Then I have a property called ConfigurationFile, which is later passed to the deferred user action, for example:
<Property Id="ConfigurationFile" Value="[#file.Product.exe.config]" />
I previously assigned the ConfigurationFile Value = "[APPLICATIONROOTDIRECTORY] \ Product.exe.config" property, which worked fine, but since we need to install the configuration in a different folder (the reason why this should have been done does not matter to this topic), I had to modify it to allow the location of the configuration file from the installer using the syntax [#file.Product.exe.config] .
When a user action receives this parameter, it is still in the format [#file.Product.exe.config] (that is, not resolved) and causes a lot of problems. I was a little embarrassed because, based on registration, it seemed like it should work. It turns out that Session.Log( ) resolves this link to the file, which led to the journal "lying" to me about the actual content of the argument.
I tried different approaches to the "clan" of this line, including session.Format() which leads to an InvalidHandleException, using a record (as indicated below) and other ways without luck.
using (Record formatRec = new Record(0)) { formatRec.FormatString = p0; return formatRec.GetString(0)
WiX has several user actions that handle this agreement. However, I have yet to figure out how they do it. Until you can dive into the source code for these custom actions.
User action arguments are retrieved from Session.CustomActionData .
Is there a good way to handle this?