[wix-users] SetProperty and PropertyRef within Fragments...
Phill Hogland
phill.hogland at rimage.com
Tue Jul 19 13:15:14 PDT 2016
I'm not sure I follow your scenario, so I will share how I do it using on of my remember property patterns
This is in Properties.wxs and actually I have many fragments in this file, and some fragments have more than one property defined in the fragment, but generally I try to make the fragments as small and focused as possible. I put this Properties.wxs file in a wixlib project and then include a reference to the wixlib in the host project. But I could have included this Properties.wxs file in a single wixproj.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<!-- <PropertyRef Id="LOGSFOLDER"/> -->
<!-- <ComponentRef Id="compLOGSFOLDER"/> -->
<Fragment>
<Property Id='LOGSFOLDER'>
<RegistrySearch Id='FindLOGSFOLDER' Root='HKLM' Key='!(wix.PropertiesRegKey)' Name='LOGSFOLDER' Type='directory'/>
</Property>
<CustomAction Id='SaveNewLOGSFOLDER' Property='CMDLINE_LOGSFOLDER' Value='[RIMAGELOGSFOLDER]' Execute='firstSequence' />
<CustomAction Id='GetSavedNewLOGSFOLDER' Property='LOGSFOLDER' Value='[CMDLINE_LOGSFOLDER]' Execute='firstSequence' />
<InstallExecuteSequence>
<Custom Action='SaveNewLOGSFOLDER' Before='AppSearch' />
<Custom Action='GetSavedNewLOGSFOLDER' After='AppSearch'>CMDLINE_LOGSFOLDER</Custom>
</InstallExecuteSequence>
<Component Id='compLOGSFOLDER' Directory="LOGSFOLDER">
<RegistryValue Root="HKMU" Key="!(wix.PropertiesRegKey)" Name="LOGSFOLDER" Value="[LOGSFOLDER]" Type="string" KeyPath="yes" />
</Component>
</Fragment>
</Wix>
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<!-- This ComponentGroup should be related to a Feature which is not advertised to assure that the bootstrapper
can initialize the default value for these common properties. Advertised features should be siblings or childern.-->
<ComponentGroup Id="MsiProperties" Directory="UtilitiesDir">
<ComponentGroupRef Id="commonProperties" />
</ComponentGroup>
</Fragment>
<Fragment>
<SetProperty Id="ARPINSTALLLOCATION" Value="[INSTALLFOLDER]" After="CostFinalize" />
<PropertyRef Id="LOGSFOLDER"/>
<ComponentGroup Id="commonProperties" Directory="CameraCalibratorDir">
<!-- RmemberProperty pattern components. One entry for each related PropertyRef in the Project. -->
<ComponentRef Id="compLOGSFOLDER"/>
</ComponentGroup>
</Fragment>
</Wix>
Then in my "main.wxs" file inside the Product element I include this:
<!-- Never advertise, as this app must be local for other apps which depend on it.. -->
<Feature Id="MyApp" Title="some title" Level="1" InstallDefault="local" TypicalDefault="install" AllowAdvertise="no">
<ComponentGroupRef Id="MsiProperties"/>
<!-- The above ref pulls in the fragment above this because MsiProperties is referenced, and even if other Property elements were included in one of the above fragments they too would get pulled in because there is atleast one item in the fragment referenced.
some other components or groups of components.-->
</Feature>
________________________________
From: wix-users <wix-users-bounces at lists.wixtoolset.org> on behalf of Lewis Henderson <henderso at opentext.com>
Sent: Tuesday, July 19, 2016 2:17:39 PM
To: WiX Toolset Users Mailing List
Subject: [wix-users] SetProperty and PropertyRef within Fragments...
Hello Folks,
I've been working with Wix for a while now, but I have some "bad habits", such as using Wix includes rather than Fragments. I'm working to correct this, but I've run into an issue. I have one Fragment that defines some properties using SetProperty statements, but PropertyRef statements for those properties in other Fragments (and the main .wxs file) come up unresolved from light. I can't just define a default property value (or can I), because the SetProperty statements are conditional. This code snippet may help:
<Fragment>
<Property Id="JRE_HOME" Secure="yes">
<RegistrySearch ... />
</Property>
<Property Id="JRE_JVM" Secure="yes">
<DirectorySearch Id="jre_jvm" Path="[JRE_HOME]\bin" Depth="1">
<FileSearch Name="jvm.dll" />
</DirectorySearch>
</Property>
<!-similar code for JDK_HOME and JDK_JVM -->
<SetProperty Id="JAVA_HOME" Value="JRE_HOME"
After="AppSearch">JRE_JVM</SetProperty>
<SetProperty Id="JAVA_HOME" Value="JDK_HOME"
After="AppSearch">NOT JAVA_HOME AND JDK_JVM</SetProperty>
...
</Fragment>
The conditions are actually a bit more complex as they're also enforcing a minimum version, but you get the idea. The problem is that in other files, when I have <PropertyRef Id="JAVA_HOME">, I get "error LGHT0094 : Unresolved reference to symbol 'Property:JAVA_HOME'".
Does anyone have a good workaround for this issue? Thanks for any assistance.
Lewis Henderson
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
WiX Support | WiX Experts and Resources from FireGiant<http://www.firegiant.com/>
www.firegiant.com
WiX Support | Installation, Development, Deployment | WiX Experts and Resources from FireGiant
More information about the wix-users
mailing list