Sending Property Value to Wix Extension Method - wix

I have a wix property
<Property Id="VAR1" Value="aValue" />
And i want to send this value into my Extension method
<Property Id="TEST" Value="$(extension.GetResult(VAR1)" />
I want to send the value aValue into the GetResult method, but cant seem to find
the correct syntax to convert VAR1 to 'aValue'
The extension is a preprocessor extension and the Property VAR1 will get set via the user interface...

Properties are only available at runtime, other than by parsing source itself.

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";

Can you assign a WiX Property to CommonAppDataFolder?

I would like to set an overrideable property for a WiX property to the current location of CommonAppDataFolder. So far I have tried the following:
<Property Id="GHOSTSCRIPT" Value="[CommonAppDataFolder]"/>
as well as
<Property Id="GHOSTSCRIPT" Value="CommonAppDataFolder"/>
Neither one resolves correctly. Is there a way to do this?
The Property element writes a row to the Windows Installer Property table. The value column is type "text" not type "formatted" so the [PROPNAME] doesn't work.
The SetProperty element schedules a Property Custom Action (Type 51) in the needed sequence and it supports what you are trying to do.
SetProperty Element

How to use a property that was set in a custom action?

I want to set a property in a custom action and use it in the standard custom action "util:User" afterwards. But no matter where I put the property in my wxs-file, I always get "error LGHT0094 : Unresolved reference to symbol"
Details:
In my setup I want to add a new user by using util:User. The user should be added to the group "Power Users" by using util:GroupRef. No Problem so far. Unfortunately the group names are language dependent. In german "Power Users" is "Hauptbenutzer". So I want to look up the well known SID S-1-5-32-547 in a custom action, set a property in this custom action by calling MsiSetProperty and then use the property for util:GroupRef.
As far as I understand, the property must be declared somewhere in the wxs-file.
In the examples I found, the property was never declared as follows (but I also tried that):
<Property Id="TextSID" Value="Power Users" />
In the examples there always was a custom action to set the property, like:
<CustomAction Id="SetTextSID"
Property="TextSID"
Value="Power Users"
Return="check" />
My problem is, that the creation of the user fails to "compile" because the property "TextSID" is not known:
<Component Id="CreateUser" Guid="Some GUID here in my original wxs file">
<util:User Id="UserUser"
Name="User" Password="Password"
CanNotChangePassword="yes" PasswordNeverExpires="yes">
<util:GroupRef Id="TextSID" />
</util:User>
</Component>
I have never done a custom action before and I'm a new to WiX and MSI, so any idea would be very welcome.
Regards
Ralf
Sorry for wasting your time.
I stared at my XML for hours before I posted this question, just to find the answer immediately after my post :-(
My only problem was, that it is not possible to reference to something that isn't there. In this case the "util:Group" was missing.