hmsinfra
asked on
Creating config XML from VBScript
Hello,
I'm trying to create a vbscript that allows me to automate some deployments to our various environments. Each environment usually has the same config files. however they have different parameters for things like sql connection strings etc. I want to have a vbscript that is able to write like a web.config file with the paramters I choose. I couldn't find anything opensoruce for this. Anyone that is familiar with vbscript able to help? Attached is a beginning sample of a web.config file that I would want to generate using a vbscript. The endpoint address is what I would want to have as a variable as it varies in the different environments. :
I'm trying to create a vbscript that allows me to automate some deployments to our various environments. Each environment usually has the same config files. however they have different parameters for things like sql connection strings etc. I want to have a vbscript that is able to write like a web.config file with the paramters I choose. I couldn't find anything opensoruce for this. Anyone that is familiar with vbscript able to help? Attached is a beginning sample of a web.config file that I would want to generate using a vbscript. The endpoint address is what I would want to have as a variable as it varies in the different environments. :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging" />
</configSections>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
propagateActivity="true">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
</listeners>
</source>
</sources>
</system.diagnostics>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add source="Enterprise Library Logging" formatter="Text Formatter"
log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"
name="Formatted EventLog TraceListener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp}
Message: {message}
Category: {category}
Priority: {priority}
EventId: {eventid}
Severity: {severity}
Title:{title}
Machine: {machine}
Application Domain: {appDomain}
Process Id: {processId}
Process Name: {processName}
Win32 Thread Id: {win32ThreadId}
Thread Name: {threadName}
Extended Properties: {dictionary({key} - {value}
)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
name="Text Formatter" />
</formatters>
<logFilters>
<add minimumPriority="0" maximumPriority="2147483647" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging" name="Priority Filter" />
</logFilters>
<categorySources>
<add switchValue="All" name="AdServer">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="ORMBinding" receiveTimeout="00:00:00.2000000"
maxConnections="1000">
<readerQuotas maxStringContentLength="16384" />
</binding>
</netTcpBinding>
</bindings>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<client>
<endpoint address="net.tcp://192.168.1.106:5151/Server"
binding="netTcpBinding" bindingConfiguration="ORMBinding" contract="abc.Frontend.Common.ICommunicationHandler"
name="ORMServer" />
</client>
</system.serviceModel>
ASKER
Hey,
That took would work for another project, but for this I don't think it will work. Sometimes under heavy load we may need to take a PERF server and move it to PROD, and sometimes the PROD servers may have like different endpoint addresses. Is there a way to use something like VBScript to edit the XML file and replace lines like the attached code?
That took would work for another project, but for this I don't think it will work. Sometimes under heavy load we may need to take a PERF server and move it to PROD, and sometimes the PROD servers may have like different endpoint addresses. Is there a way to use something like VBScript to edit the XML file and replace lines like the attached code?
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<client>
<endpoint address="net.tcp://111.111.111.111:5050/Server"
binding="netTcpBinding" bindingConfiguration="OMBinding" contract="abc.Frontend.Common.ICommunicationHandler"
name="ORServer" />
</client>
</system.serviceModel>
replace the endpoint address= with
<endpoint address="net.tcp://999.999.999.999:5050/Server"
binding="netTcpBinding" bindingConfiguration="OMBinding" contract="abc.Frontend.Common.ICommunicationHandler"
name="ORServer" />
See only the IP address changed?
ASKER
Also I found this page
http://www.devguru.com/technologies/xml_dom/15891.asp
Which makes it seem like its easy to simply add an attibute/replace. I however can't seem to get it working. Can anyone test and give me an example on how to replace the attributes?
Thanks!
http://www.devguru.com/technologies/xml_dom/15891.asp
Which makes it seem like its easy to simply add an attibute/replace. I however can't seem to get it working. Can anyone test and give me an example on how to replace the attributes?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
We are using T4 to solve the same problem that you have with multiple environments with just connection string and endpoint that is diffrent in our config files.
http://www.olegsych.com/2007/12/how-to-use-t4-to-generate-config-files/
and
http://www.olegsych.com/2007/12/text-template-transformation-toolkit/
When you have it in place it works great for us.
Best Regrds Tompa