Using CTT to modify config files for different environments

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 @ Sunday, December 04, 2011 10:47 PM
Print

Comments on this entry:

No comments posted yet.

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«May»
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789