Hallo all,
could you help me, please? I need to update XML file with user-entered
value. I use folowing example code:
UI fragment:
------------------------------------------------------------------------------------------------
    <UI>
      <Binary Id="BannerBitmap" SourceFile="Banner.bmp" />
      <Property Id="BannerBitmap">bannrbmp</Property>
      <Property Id="USERN" />

      <TextStyle Id="Font1" FaceName="Tahoma" Size="10" Bold="yes" />

      <Dialog  Id="DBConnDlg" Width="370" Height="270"
Title="[ProductName] [Setup]" >

        <Control Id="Banner" Type="Bitmap" X="0" Y="0" Width="450"
Height="44" TabSkip="no" Text="BannerBitmap" />

        <Control Id="Title" Type="Text" X="15" Y="6" Width="200"
Height="15" Transparent="yes" NoPrefix="yes">
          <Text>{\Font1}Module Test</Text>
        </Control>

        <Control Id="Description" Type="Text" X="25" Y="23"
Width="280" Height="15" Transparent="yes" NoPrefix="yes">
          <Text>Please specify DB connection string for Test Service</Text>
        </Control>
        <!--  -->

        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370"
Height="0" />

        <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370"
Height="0" />

        <!-- EDIT-->
        <Control Id="LblUser" Type="Text" X="40" Y="80" Width="51"
Height="17" TabSkip="yes" Property="USERN">
          <Text>User name:</Text>
        </Control>
------------------------------------------------------------------------------------------------

The important part is the code under  <!-- EDIT--> comment. There is
the code fragment for updating the XML:
------------------------------------------------------------------------------------------------
<Component Id='Settings' Guid='{D73AD5A0-E909-464a-ABDC-3AC8E71DC8AB}'>
          <File Id='XmlSettings' Name='Srv.cfg'
LongName='SecurityService.exe.config'
Source='SecurityService.exe.config'  />

          <XmlFile Id='XmlSettings2' File='[INSTALLDIR]\Module
1\SecurityService.exe.config'
            Action='setValue' Name='connectionString' Value='User
ID=[USERN];Password=xxx;Data Source=xxx'
ElementPath='//configuration/connectionStrings/add'
            Sequence='2' />

        </Component>
------------------------------------------------------------------------------------------------
So I need to update "User ID=[USERN];" (with "USERN property). After
installation is replaced only text without "USERN " value ("User
ID=;").
Can you help me, please? The whole code looks like this:

------------------------------------------------------------------------------------------------
<?xml version='1.0' encoding='Windows-1252'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";>
  <Module Id="Module1" Guid="D7BC5F3A-6279-4a11-9D9E-01B78296CB4E"
Language="0" Version="4.0.0">

    <Package Id="{F2248627-6719-46b7-9505-0F5B6F1A4A3D}" InstallerVersion="200"
      Languages="1033" Manufacturer="SITRONICS Telecom Solutions,
Czech Republic a. s." SummaryCodepage="1252" AdminImage="no"
ShortNames="no" />

<!--   <Package Id="????????-????-????-????-????????????" InstallerVersion="200"
      Languages="1033" Manufacturer="SITRONICS Telecom Solutions,
Czech Republic a. s." SummaryCodepage="1252" AdminImage="no"
ShortNames="no" />
-->
    <!-- ###################### CUSTOM DIALOG
####################################################### -->
    <UI>
      <Binary Id="BannerBitmap" SourceFile="Banner.bmp" />
      <Property Id="BannerBitmap">bannrbmp</Property>
      <Property Id="USERN" />

      <TextStyle Id="Font1" FaceName="Tahoma" Size="10" Bold="yes" />

      <Dialog  Id="DBConnDlg" Width="370" Height="270"
Title="[ProductName] [Setup]" >

        <Control Id="Banner" Type="Bitmap" X="0" Y="0" Width="450"
Height="44" TabSkip="no" Text="BannerBitmap" />

        <Control Id="Title" Type="Text" X="15" Y="6" Width="200"
Height="15" Transparent="yes" NoPrefix="yes">
          <Text>{\Font1}Module Test</Text>
        </Control>

        <Control Id="Description" Type="Text" X="25" Y="23"
Width="280" Height="15" Transparent="yes" NoPrefix="yes">
          <Text>Please specify DB connection string for Test Service</Text>
        </Control>
        <!--  -->

        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370"
Height="0" />

        <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370"
Height="0" />

        <!-- EDIT-->
        <Control Id="LblUser" Type="Text" X="40" Y="80" Width="51"
Height="17" TabSkip="yes" Property="USERN">
          <Text>User name:</Text>
        </Control>
        <Control Id="LblPwd" Type="Text" X="40" Y="111" Width="51"
Height="17" TabSkip="yes">
          <Text>Password:</Text>
        </Control>
        <Control Id="LblSrc" Type="Text" X="40" Y="142" Width="51"
Height="17" TabSkip="yes">
          <Text>Source:</Text>
        </Control>

        <Control Text="sec" Id="EdtUsr" Type="Edit" X="95" Y="78"
Width="150" Height="15" Property="_edtUsr">

        </Control>
        <Control Id="EditPwd" Type="Edit" X="95" Y="109" Width="150"
Height="15" TabSkip="no" Password="yes" Property="_edtPwd">
          <Text>sec</Text>
        </Control>
        <Control Id="EditSrc" Type="Edit" X="95" Y="140" Width="150"
Height="15" TabSkip="no" Property="_edtSrc">
          <Text>foris</Text>
        </Control>

        <!---->
        <Control Id="buttonNext" Type="PushButton" X="244" Y="244"
Width="56" Height="17" TabSkip="no">
          <Text>&amp;Next &gt;</Text>
          <Publish Event="EndDialog" Value="Return" />
        </Control>
        <Control Id="buttonCancel" Type="PushButton" X="309" Y="244"
Width="56" Height="17" TabSkip="no">
          <Text>Cancel</Text>
          <Publish Event="SpawnDialog" Value="CancelDlg"/>
        </Control>

      </Dialog>

      <AdminUISequence/>

      <InstallUISequence>

        <!--<Show Dialog="DBConnDlg" After="ExecuteAction" ></Show>-->

        <Show Dialog="DBConnDlg" After="CostFinalize" ></Show>
        <LaunchConditions After='AppSearch' />
      </InstallUISequence>

    </UI>

    <!-- ###################### CUSTOM DIALOG
####################################################### -->

    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='INSTALLDIR' Name='Module1' LongName='Module 1'>

        <!-- ###################### MODIFY XML VALUE
################################################ -->
        <Component Id='Settings' Guid='{D73AD5A0-E909-464a-ABDC-3AC8E71DC8AB}'>
          <File Id='XmlSettings' Name='Srv.cfg'
LongName='SecurityService.exe.config'
Source='SecurityService.exe.config'  />

          <XmlFile Id='XmlSettings2' File='[INSTALLDIR]\Module
1\SecurityService.exe.config'
            Action='setValue' Name='connectionString' Value='User
ID=[USERN];Password=xxx;Data Source=xxx'
ElementPath='//configuration/connectionStrings/add'
            Sequence='2' />

        </Component>

      </Directory>
    </Directory>

    <AdminExecuteSequence />

    <InstallExecuteSequence>
      <!--      <Custom Action='XmlSettings' After='DBConnDlg'></Custom>-->
    </InstallExecuteSequence>
  </Module>
</Wix>
------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to