XDT Manual Transform

I have the following scenario: a file called App.ENV.config,
I use a powerhell script to swop out escaped statements in this config with variables from octopus. The trick is, the project gets deployed and transformed on the tentacle before the swopping can happen as I need the app.env.config deployed there.
I need to manually transform this env.config into the app.config AFTER the dpeloyment via an Octopus Powershell step.
What would the command be for this transformation from octopus?

thanks In advance


Are you currently putting your PowerShell statements into Deploy.ps1?

If so, put them in PreDeploy.ps1 instead. This runs prior to the config transforms.


Hi Paul,
thanks for the reply. I have moved my powershell to the predeploy and it is successfully altering the app.ENV.config in the C:\Octopus\Applications\DEV01\Online.Service.BPR\1.0.214-Stampede folder; however it is not applying the transform. I have specified in the deployment step to do an additional transformation on the app.ENV.config but as far as I can tell, nothing changes.
[added] basically I want to apply the app.DEV01.config transform and then ANOTHER app.ENV.config transform.
Is this at all possible?


Hi Wilken,

When you have an app.config file, and your project is called Online.Service.BPR.exe (for example), the actual file at deployment time will be “Online.Service.BPR.exe.config”.

The transforms need to mirror this - so instead of “app.DEV01.config”, the file would need to be called “Online.Service.BPR.exe.DEV01.config”, in order for Octopus to recognize it.

Hope that helps,


Hi Paul, thanks for the reply. In this case, we have both an ENV.config and DEV01.config. The DEV01 is applied first and then the ENV. The idea was to use the ENV config with octopus params to do away with the DEV01/QAS01 etc. ATM we run them parallel as not to influence other branches. I have resolved it by including some powershell as a step; I’ll explain my resolution just now.


I’m sure there’s better ways to do it, but nevertheless here’s my explanation:


PreDeploy.ps1-> should contain powershell to swop out variables. This will create the app.ENV.config in the install folder on the tentacle. On deployment the app.ENV.config will move to the Application Folder and normal tranforms will be done; DEV01-> app.config
We use team city as a build engine so Octopus will not automatically transform app.config to service.exe.config

a manual transform can be done by loading the following dll’s into powershell, to execute from octopus, these dll’s must be on the tentacle:

once the app.ENV config has been transformed into the app.config another step can be added to rename the app.config to service.exe.config

crude Function to manually transform xdt:
function XmlDocTransform($xml, $xdt, $scriptPath )
$xml= $scriptPath + $xml
$xdt= $scriptPath + $xdt
if (!$xml -or !(Test-Path -path $xml -PathType Leaf)) {
throw “XML File not found. $xml”;
if (!$xdt -or !(Test-Path -path $xdt -PathType Leaf)) {
throw “XDT File not found. $xdt”;
$transformPath = $scriptPath + “Microsoft.Web.XmlTransform.dll”

$transformPath =  $scriptPath+ "Microsoft.Web.Publishing.Tasks.dll"

$xmldoc = New-Object Microsoft.Web.XmlTransform.XmlTransformableDocument;
$xmldoc.PreserveWhitespace = $true

$transf = New-Object Microsoft.Web.XmlTransform.XmlTransformation($xdt);
if ($transf.Apply($xmldoc) -eq $false)
    throw "Transformation failed."

$DeployedDir=$OctopusParameters[“a_ServiceFolder”] + "\Online-Service"
XmlDocTransform “app.config” “app.ENV.config” “$DeployedDir”