Simon,
Here is my test app using the Foobar files from a tutorial plus a deployed 
App.Config file (could've used a web.config or *.exe.config).  Fairly self 
explanatory - I hope.

SampleRegistry.ini reads
[COMPUTER_NAME1]
AnyOldKeyNameIChooseForMyIniFile=AnyOldValue

[COMPUTER_NAME2]
AnyOldKeyNameIChooseForMyIniFile=DifferentOldValue
.
.
.
and so on.

<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
  <Product Name='Foobar 1.0' Id='{A0B7E37C-46D9-4c41-B79C-85841092C448}'
    Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Acme Ltd.' 
UpgradeCode='{6988A5C7-9C2A-4fb8-B6A7-3E0003A78317}'>

    <Package Id='{AEB90E9D-5E24-4aec-9ED4-CFB0511CCFC0}' Keywords='Installer'
      Description="Acme's Foobar 1.0 Installer"
      Comments='Foobar is a registered trademark of Acme Ltd.' 
Manufacturer='Acme Ltd.'
      InstallerVersion='100' Languages='1033' Compressed='yes' 
SummaryCodepage='1252' />

    <!--This looks into the localcomputer registry to find the computer name-->
    <Property Id="MYCOMPUTER_NAME">
      <RegistrySearch Id="TestRegistrySearch" Type="raw" Root="HKLM" 
Key="System\CurrentControlSet\Control\ComputerName\ComputerName"
        Name='ComputerName' />
    </Property>
    
    <!--This looks into the SampleRegistry.ini in WINDOWS directory for a given 
computer name section-->
    <Property Id="MY_APP_CONFIG_VALUE">
      <IniFileSearch Id='TestIniFile' Type='raw' Name='Sample.ini' 
LongName='SampleRegistry.ini' Section="[MYCOMPUTER_NAME]" 
Key='AnyOldKeyNameIChooseForMyIniFile' Field='1' />
    </Property>    

    <Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
    <Property Id='DiskPrompt' Value="Acme's Foobar 1.0 Installation [1]" />

    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder' Name='PFiles'>
        <Directory Id='Acme' Name='Acme'>
          <Directory Id='INSTALLDIR' Name='Foobar10' LongName='Foobar 1.0'>

            <Component Id='MainExecutable' 
Guid='{8CD20A89-46D4-4e56-A5D3-41A23DD621CF}'>
              <File Id='FoobarEXE' Name='Foobar10.exe' 
LongName='FoobarAppl10.exe' DiskId='1'
                Source='FoobarAppl10.exe' Vital='yes'>
                <Shortcut Id="startmenuFoobar10" Directory="ProgramMenuDir" 
Name="Foobar10" 
                  LongName="Foobar 1.0" WorkingDirectory='INSTALLDIR' 
Icon="Foobar10.exe" IconIndex="0" />
                <Shortcut Id="desktopFoobar10" Directory="DesktopFolder" 
Name="Foobar10"
                  LongName="Foobar 1.0" WorkingDirectory='INSTALLDIR' 
Icon="Foobar10.exe" IconIndex="0" />
              </File>
            </Component>

            <Component Id='HelperLibrary' 
Guid='{3E12C7ED-0A24-41a3-AE18-8524074F154F}'>
              <File Id='HelperDLL' Name='Helper.dll' DiskId='1' 
Source='Helper.dll' Vital='yes' />
            </Component>

            <Component Id='Manual' 
Guid='{FCA73FF6-FC0F-426a-A165-5CB042C31B3B}'>
              <File Id='Manual' Name='Manual.pdf' DiskId='1' 
Source='Manual.pdf'>
                <Shortcut Id="startmenuManual" Directory="ProgramMenuDir" 
Name="Manual" LongName="Instruction Manual" />
              </File>
            </Component>
            <Component Id='App_Config' 
Guid='{BBA431E9-51DB-49a5-827E-0FD1EAF17C05}'>
              <File Id='App_Config' Name='App.cfg' LongName='App.Config' 
DiskId='1' Source='App.Config' Vital='yes'> </File>
              <XmlFile Id='AppCongifSettings' File='[INSTALLDIR]App.Config' 
Action='setValue' Value="[MY_APP_CONFIG_VALUE]" 
ElementPath="/configuration/appSettings/[EMAIL 
PROTECTED]'AppConfigKeyName'[\]]/@value" />             
            </Component>
          </Directory>
        </Directory>
      </Directory>

      <Directory Id="ProgramMenuFolder" Name="PMenu" LongName="Programs">
        <Directory Id="ProgramMenuDir" Name='Foobar10' LongName="Foobar 1.0" />
      </Directory>

      <Directory Id="DesktopFolder" Name="Desktop" />
    </Directory>

    <Feature Id='Complete' Level='1'>
      <ComponentRef Id='MainExecutable' />
      <ComponentRef Id='HelperLibrary' />
      <ComponentRef Id='Manual' />
      <ComponentRef Id='App_Config' />      
    </Feature>

    <Icon Id="Foobar10.exe" SourceFile="FoobarAppl10.exe" />

  </Product>
</Wix>    


Kind regards,
National Oilwell Varco

John Crouch
Software Engineer/Developer

National Oilwell Norway AS
Phone: +4751818181
Fax:     +4751800547
[EMAIL PROTECTED]
www.nov.com

This message, including any attachments, is intended only for the addressee and 
may contain privileged or confidential information. Any unauthorized disclosure 
is strictly prohibited. If you receive this message in error, please notify us 
immediately so that we may correct our internal records. Please then delete the 
original message. Thank you.
________________________________________
From: Simon Burgess [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 14, 2006 2:16 PM
To: Crouch, John; wix-users@lists.sourceforge.net
Subject: RE: [WiX-users] string replacement in xml files

Thanks John that's good to know someone out there is going through the same 
thing ;-) Could I possibly get a peek at your WiX source that would replace a 
value within some XML as all I can see from the help is how to create a new 
element

________________________________________
From: Crouch, John [mailto:[EMAIL PROTECTED] 
Sent: 14 September 2006 06:20
To: wix-users@lists.sourceforge.net
Cc: Simon Burgess
Subject: RE: [WiX-users] string replacement in xml files

Simon,
I have a very similar issue for an enterprise deployment next year.  I am 
currently using an .ini file which keeps all data for all the deployment 
locations by computer name (which I know in advance).
[NY-SRV-01]
This-web-config=127.0.0.1
This-exe-config=127.0.0.2

[SF-SRV-02]
This-web-config=721.0.0.1
This-exe-config=721.0.0.2

Then in my WiX generated msi I
1. Look into the registry for the computer name - assign that to a value
2. Look up the computer name matching the previous value in my *.ini file
3. Read off the values that this particular msi requires.
4. Use XMLFile to update the key values in my web and app config files.

Works fine, however, I am open to any suggestions to improve it.


Kind regards,
National Oilwell Varco

John Crouch
Software Engineer/Developer

National Oilwell Norway AS
Phone: +4751818181
Fax:     +4751800547
[EMAIL PROTECTED]
www.nov.com

This message, including any attachments, is intended only for the addressee and 
may contain privileged or confidential information. Any unauthorized disclosure 
is strictly prohibited. If you receive this message in error, please notify us 
immediately so that we may correct our internal records. Please then delete the 
original message. Thank you.
________________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Simon Burgess
Sent: Wednesday, September 13, 2006 10:48 PM
To: 'WiX-users'
Subject: [WiX-users] string replacement in xml files

I am looking into different ways to handle environment specific information in 
web.config files. It would seem logical if at deployment time, my installer 
could determine where it is being run and update a generic config file so that 
is fit for purpose for the environment it is being run on. I wouldn't need to 
create new elements exactly but just search for partular tokens within an xml 
file and replace them with a value I read in from the registry for example. The 
following is some sample xml from a config file:

<endpoint address="http://localhost/Configuration/ConfigurationService.svc"; 
binding="basicHttpBinding" 
bindingConfiguration="BasicHttpBinding_IConfigurationService" 
contract="Exchange.EnterpriseLibrary.Configuration.IConfigurationService" 
name="BasicHttpBinding_IConfigurationService"/>
I would need to replace 'localhost' with something more appropriate. Is this 
something the XMLFile element could handle or is there something else in WiX 
that could help out?

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to