Arguments:
  • source: (s:) - source file path
  • transform: (t:) - transform file path
  • destination: (d:) - destination file path
  • parameters: (p:) - (Optional parameter) string of parameters used expected by source file separated by ';', value should be separated from name by ':', if value contains spaces - quote it
  • fpt - (Optional parameter) force parameters task (if parameters argument is empty, but need to apply default values), default is false
  • v - (Optional parameter) verbose output.

Example 1 (Without parameters):

source.config file content:
<?xml version="1.0"?>

<configuration>

	<custom>
		<groups>
			<group name="TestGroup1">
				<values>
					<value key="Test1" value="True" />
					<value key="Test2" value="600" />
				</values>
			</group>

			<group name="TestGroup2">
				<values>
					<value key="Test3" value="True" />
				</values>
			</group>

		</groups>
	</custom>
	
</configuration>

transform.config file content:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
	
	<custom>
		<groups>
			<group name="TestGroup1">
				<values>
					<value key="Test2" value="601" xdt:Transform="Replace"  xdt:Locator="Match(key)" />
				</values>
			</group>
		</groups>
	</custom>
	
</configuration>

Then you can use one of the command line
ctt.exe source:"source.config" transform:"transform.config" destination:"destination.config"
ctt.exe s:source.config t:transform.config d:destination.config

destination.config file will have content:
<?xml version="1.0"?>

<configuration>

	<custom>
		<groups>
			<group name="TestGroup1">
				<values>
					<value key="Test1" value="True" />
					<value key="Test2" value="601" />
				</values>
			</group>

			<group name="TestGroup2">
				<values>
					<value key="Test3" value="True" />
				</values>
			</group>

		</groups>
	</custom>
	
</configuration>

Example 2 (With parameters):

source.config file content:
<?xml version="1.0"?>

<configuration>

	<custom>
		<groups>
			<group name="TestGroup1">
				<values>
					<value key="Test1" value="False" />
					<value key="Test2" value="600" />
				</values>
			</group>

			<group name="TestGroup2">
				<values>
					<value key="Test3" value="C:\Test\" />
				</values>
			</group>

		</groups>
	</custom>
	
</configuration>

transform.config file content (two parameters there: Parameter1 with default value and Test3Value):
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
	
	<custom>
		<groups>
			<group name="TestGroup1">
				<values>
					<value key="Test2" value="601" xdt:Transform="Replace"  xdt:Locator="Match(key)" />
					<value key="Test1" value="{Parameter1:True5665}" xdt:Transform="Replace"  xdt:Locator="Match(key)" />
				</values>
			</group>
			
			<group name="TestGroup2">
				<values>
					<value key="Test3" value="{Test3Value}" xdt:Transform="Replace"  xdt:Locator="Match(key)" />
				</values>
			</group>
		</groups>
	</custom>
	
</configuration>

Command line with parameters:
ctt.exe s:s.config t:t.config d:d.config p:Parameter1:True;Test3Value:"c:\Program Files\Test""

after execution destination.config file will have content:
<?xml version="1.0"?>
<configuration>
  <custom>
    <groups>
      <group name="TestGroup1">
        <values>
          <value key="Test1" value="True" />
          <value key="Test2" value="601" />
        </values>
      </group>
      <group name="TestGroup2">
        <values>
          <value key="Test3" value="c:\Program Files\Test" />
        </values>
      </group>
    </groups>
  </custom>
</configuration>

Links

Last edited Jan 14, 2013 at 6:25 PM by outcoldman, version 8

Comments

zmme Dec 23, 2011 at 11:58 AM 
@mfreidge: thanks for the link - very cool!

mfreidge Dec 2, 2011 at 9:09 PM 
To test online your Transformation you can use Transformation Tester
http://webconfigtransformationtester.apphb.com/