Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com

Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com
We previously tried to use msbuild to adjust configuration files for different environments.
Recently I found C onfig Transformation Tool(CTT) on CodePlex and with addition of global replace using powershell it is enough and easier to do all required modifications

Content of ChangeConfig.cmd:
ctt s:..\web.config t:WebConfig.CTT d:..\web.config
powershell.exe -command "Get-Content ..\Remoting.config | ForEach-Object { $_ -replace '//localhost/ServicesCI/', '//ServerName01/ServicesCI/' } | Set-Content ..\remoting.temp"
powershell.exe -command "copy  ..\remoting.temp ..\remoting.config"
ctt s:..\EnterpriseLibraryLogging.config t:EnterpriseLibraryLogging.CTT d:..\EnterpriseLibraryLogging.config
@goto end
@rem some code that currently not used
:End
@pause


Content of example WebConfig.CTT :

<? xml version="1.0"?>
<
configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<
appSettings >
<
add key="ShowDeveloperExceptionInfo" value="False" xdt:Transform="Replace"  xdt:Locator="Match(key)" />
</
appSettings >
<
system.diagnostics >
<
sharedListeners >
<
add name="ServiceModelMessageLoggingListener" initializeData="C:\temp\testCIcopy2.svclog"   xdt:Locator="Match(name)" xdt:Transform="SetAttributes(initializeData)"   />
</
sharedListeners >
</
system.diagnostics >
</
configuration >

Extract from web.config - sharedListeners section

 < sharedListeners >
       <
add initializeData="C:\temp\TEST.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
       <
filter type="" />
     </ add >
   </
sharedListeners >v
Posted on Sunday, December 4, 2011 10:47 PM Deployment , Batch files/PowerShell | Back to top


Comments on this post: Using CTT to modify config files for different environments

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net