Additional Transforms: Conditional transform

Confirming that conditional statements are still not possible from Features/Additional Transforms sub step.
I’d like to be able to conditionally apply a transform to a subset of deployment targets scoped by environment. e.g. Staging and Prod environment deployments only.

e.g. if #{Tenant.RunConditionalConfigTransform}
ConditionalConfig -> Web.Config

Hi Bill,

Thanks for getting in touch. Conditionally applying transforms for the deployment target is not supported. We think to achieve the outcome you’re after it would be best to use Octopus variables, have the transformation populate configuration files with Octopus variables that you then define different values by scoping values for the deployment target.

We have some detailed documentation on variable scoping here:,applicationSettingsandconnectionStrings
and how to do use the Octopus variable syntax here:

Let us know if you’re still having issues.


Actually what I’m trying to acheive is applying a set of transforms only to Staging and Production and not QC environments. So it’s not the scoped values that are solely of interest. It’s issues such as adding or removing various elements to both Staging and Production configs. If I were able to configure the conditional application of a common Staging/Prod transforms, it would allow me to not have to copy same transforms into multiple transform files.

I also have to use Additional Transforms as Visual Studio’s naming convention for app.config doesn’t work well with Octopus’ convention. No big issue. Just noting I’m not using the default transform process. But something like: {VsAppConfigTransformFile} => app.config in Additional Transforms.

If there’s another way to acheive this please let me know.


Hi Bill,

Could you let me know what you tried, and what you saw going wrong?

When I review our docs on the order that evaluation happens:

I see that Substitute Octopus Variables in files happens before XML Configuration Transforms

If you wrap your transforms in conditional blocks and check the environment via the Octopus variables like this:

#{if Octopus.Environment.Name == "Staging" } 
   // ... config for staging here ...
#{if Octopus.Environment.Name == "Production" } 
  // ... config for production here ...

Those sections should get omitted, based on where it’s deploying, and then the transform will happen.

Let me know how you go.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.