how to resolve burn variables in the bootstrap xml - variables

One of my goals in creating the bootstrap project is to set a default log location. I would like the location to be based on the local app data folder. I cannot figure out how to reference the builtin Burn variable LocalAppDataFolder. I have found information about how to reference these variables in code, but not in the xml.
The reference to the property looks like this:
<MsiPackage SourceFile="MyInstaller.msi" LogPathVariable="[LogLocation]" />
The property is set like this:
<Variable Name="LogLocation" Value="[LocalAppDataFolder]MyLogFolder\Setup" Type="string"/>
The log output shows:
Initializing string variable 'LogLocation' to value
'[LocalAppDataFolder]MyLogFolder\Setup'
What am I missing to resolve [LocalAppDataFolder] ?
thanks in advance.

It's normal for the log output to show the un-formatted value, so that part looks correct. I think what you are missing is LogPathVariable should be specified without the brackets.
<MsiPackage SourceFile="MyInstaller.msi" LogPathVariable="LogLocation" />

Related

Wix Installer - Getting data from a Property

I am using Wix to make an installer and I was wondering how I indirectly get a property's value.
Like if I have a Property WIXUI_INSTALLDIR that is preset with the INSTALLFOLDER value
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
and this Property then is changed through a a Dialog from user input and I after that would want to get what the user changed the path to, how do I get the "value" out of WIXUI_INSTALLDIR ?
I would like to send this value (a string I suppose) to either the registry or a custom action.
If I try [WIXUI_INSTALLDIR] I get a warning for illegal indirection if used with a custom action and if I try to send it to registry it just becomes "[WIXUI_INSTALLDIR]" as a string.
EDIT:
My problem is when also using my own made up properties like this:
Property Id="MyOwnProperty" Value="Hello There"
and let's say a Dialogue changes the value of MyOwnProperty, how do I the access the new Value ? Like sending [MyOwnProperty] to a CustomAction as parameter will only get "[MyOwnProperty]" as a literal string.
Try getting the value of the Property (or Directory) that WIXUI_INSTALLDIR references. In this case, use [INSTALLFOLDER] in the formatted field where you'd like the value.

How to access a property value in MSI within MSM (Merge module)

I'm currently implementing a wix(3.8) installer and the main MSI is merged with several other merge modules. I'm taking a user input during the installation and I store it in a global property called PORT like this.
In the MSI
<Property Id='PORT' Value="1">
I need to access this property value inside a condition in my merge module to edit a XML file if that condition is true. So I passed this property to the merge module as a configuration like this.
In MSI
<ConfigurationData Name="PROTOCOL" Value="[PORT]" />
In MSM
<Property Id="protocol"/>
<Configuration Name="PROTOCOL" Format="Text" DefaultValue="[protocol]"/>
<Substitution Table='CustomAction' Row='SetProtocol' Column='Target' Value='[=PROTOCOL]'/>
<CustomAction Id='SetProtocol' Property='protocol' Value='[protocol]'/>
I used the value of the property "protocol" inside my condition as below but the condition never executes.
<Condition>protocol = 1</Condition>
I tried by appending the property id with the merge module's GUID as well like this and accessing that property "NEWPORT" inside the condition. but didn't success.
<Property Id='NEWPORT' Value='[protocol.8c2910c9-5694-4312-a4cc-c9b2c2a5caa5]'/>
What would be the reason for this ? Can someone please tell me the way to access the property value in MSI within Merge module's condition element.
Thanks in advance.

WiX bind property (or any other custom data) into bundle

I want to define some static information in my WiX package, doesn't matter how - a Property, a WixVariable or even a preprocessor <?define?> variable.
After that, I want to pass that piece of information into the Bundle project, maybe with Burn's Binder Variables. How can I do it?
I need something like:
!(bind.myDefinedInformation.PackageID)
To pass variables to what I assume, in your case, is a Custom BootstrapperApplication you can add a Variable sub-element to your Bundle element inside Bundle.wxs, e.g.:
<Variable Name="USERID" Type="string" Value="user" bal:Overridable="yes" />
Note: with this code you need to add:
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
to your Wix header.
In your BootstrapperApplication code you can the reference this variable like so:
var user = Engine.StringVariables["USERID"];
Or even set it like so:
Engine.StringVariables["USERID"] = "test";

How to set boolean in xml-action script

I am trying to set a flag so I do something like this:
<set field="existingFound" value="false" type="Boolean"/>
but the following line prints "true" in the log:
<log message="storeProperty, existingFound (0): ${existingFound}"/>
What is the best way to set flags?
The set.#value attribute is interpreted as a Groovy String (GString) so any non-empty value will be interpreted as true. The set.#from attribute is interpreted as a Groovy expression, so simply using from="false" instead of value="false" will get the desired result.
To see the generated Groovy code from an XML actions block you can write code that will cause an error and then the script will be logged, or you can change the log4j.xml file to turn on "debug" level logging for the XmlActions class (the latest log4j.xml file in the GitHub repository has an example of this). Looking at the Groovy code generated from the XML elements is a good way to track down issues when what is happening just doesn't make sense.

How to read runtime Macro in Wix

I Just want to read a name from a file or read from command line after creating installer file.
I have defined a Macro in my MainProject.wxs file as
< ?define product = "xyz"?>
And I am reading the Macro "product" as follows,
< Registry Action="write"
Id="RegistryEntryId"
Name="InstallDir"
Key="Software\$(var.product)\MyOwnName"
Root="HKLM"
Type="string"
Value="[INSTALLPATH]"
KeyPath="yes"/>
on build time.
But I want to define and read this "product" on runtime after the installer is created, so that I can change the product name according to the file content on runtime, any suggestions would be helpful.
Thanks in Advance.
A macro is handled by a preprocessor. What you request is a variable that can be changed at runtime. You need to use a property.
<Property Id="PROJECTNAME">xyz</Property>
This property can be changed at runtime.
You read the property like this:
[PROJECTNAME]
There are different ways of changing the property. You could do that in a custom action.