This I think requires knowledge of XPath and nant as the replacement text is variable.

I have a configuration file that looks like:

<configuration>
    <!-- Use this section to specify the application specific configuration for the 
log file
         Note: The value set here is directly tied to the location of the application 
server
               log file so this section needs to be in place for the <listeners> 
section to work.
    -->
    <appSettings>
            <add key="LogPath" value="C:\\Program 
Files\\Visa\\ApplicationServer\\appLogs\\" />
    </appSettings>
    <system.diagnostics>
                <trace autoflush="true" indentsize="4">
                        <listeners>
                                <add name="debugOut" 
type="System.Diagnostics.DefaultTraceListener" />
                                <add name="consoleOut" 
type="visa.dps.ppc.DynamicFileTraceListener, ErrorLog" 
initializeData="ApplicationServer.log" />
                                <add name="eventOut" 
type="visa.dps.ppc.EventTraceListener, ErrorLog" />
                                <remove name="debugOut" />
                        </listeners>
                </trace>
                <switches>
                        <add name="TraceSwitch" value="3" />
                </switches>
    </system.diagnostics>
</configuration>

I would like to replace every occurance of 'ErrorLog' with 
'ErrorLog,Version=3.4.5.0,Culture=neutral,PublicKeyToken=33cdfc7f7eb6be4b'. I am 
assuming that the best method would be to use the <xmlpoke> task. So as a beginning I 
have:

<xmlpoke file="App.config" 
xpath="/configuration/system.diagnostics/trace/listeners/[EMAIL PROTECTED] = 
'ErrorLog']/@value" 
value="ErrorLog,Version=3.4.5.0,Culture=neutral,PublicKeyToken=33cdfc7f7eb6be4b" /> 

Naturally this does not work.
I need to dynamically generate the version string (a property?) and put that in the 
'value' attribute for <xmlpoke>.
Also I need to replace '@type =' with some sort of substring so that only 'ErrorLog' 
is replaced. If the version string and public key token was a property then I could 
have:

<xmlpoke file="App.config" 
xpath="/configuration/system.diagnostics/trace/listeners/[EMAIL PROTECTED] = 
'ErrorLog']/@value" 
value="ErrorLog,Version=${version},Culture=neutral,PublicKeyToken=${key}" /> 

Any suggestions as to how to replace just the 'ErrorLog' portion of the type attribute?

Kevin



-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_idU88&alloc_id065&op=click
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to