Web.config transformation per machine

Hi,

I want to transform the web.config only for one machine in an environment. In my PreDeploy.ps1 script in the web project, I copy files from a sub folder to the web application root folder. I’ve created a file with transforms named web.MACHINE.config, and web.ENVIRONMENT.MACHINE.config, but none of them work. I’ve checked the “XML Transforms”, and also tried to add the filename above to the “Additional Transforms” without success.

The log doesn’t say anything about transforms more than “Looking for any configuration transformation files”.

Will the transformations take place in the “Beginning deployment”-phase before PreDeploy is run, could that be the problem?

Will transformations be done on only the root folder or does it recursively transform all config files?

Any tips?

Brgds

Jonas

Hi Jonas,

The transforms feature doesn’t support transforms per-machine out of the box, but it should be fairly straightforward to set up.

In the Additional config transforms text area, enter:

#{Octopus.Machine.Name}.config

You can alternatively set up a bound variable to contain the names of additional transforms, and use that here if there are issues using the machine name binding this way.

Regarding execution order, we’ve got some basic docs on this here now: http://docs.octopusdeploy.com/display/OD/Package+deployment+feature+ordering

Regards,
Nick

Hi,

I can’t get this to work. I’ve tried to enter “web#{Octopus.Machine.Name].config”, the actual name “web.OCTOPUSDEV.config” in the “Additional config transform”.

Do the config file and transform file need to be in the root of the web application?

Brgds

Jonas

Hi Jonas,

The additional config name should only be the extension, e.g. Foo.config if the machine is called “Foo” will transform Web.config using Web.Foo.config - does this help?

The config transformation search is recursive - all sub-folders are considered.

Regards,
Nick

Hi again,

I renamed the file to OCTOPUSDEV.config, and changed the field “Additional transforms” to “#{Octopus.Machine.Name}.config”, but the transform doesn’t kick in. I also tried with a blank value for the “Additional transforms” and only “Automatically run configuration transformation files” checked, but no success.

The log doesn’t show any indication of finding my transformation files either.

Brgds

Jonas

Hi Jonas,

The file needs to be Something.OCTOPUSDEV.config in order to transform Something.config - with the transform set to #{Octopus.Machine.Name}.config.

Regards,
Nick

Can you explain this a little more? I’ve been having an issue setting up some rewrite rules using powershell for two specific environment deploys on a single machine - so I’d like to just use a simple transform. It sounds like this is possible, since I have a unique step for each - I just need to create a config file for each.

Let’s say the machine is named LOCATIONONE, and I need transforms performed for both Acceptance and Production environments. What would that look like?

Hi,

Thanks for getting in touch! If I am understanding this correctly you should just have to use the Configuration Files feature as is.
Here is some documentation about how it works and how to name your files:

Vanessa

Vanessa,

Thanks for the reply. I guess I mean that what’s documented isn’t quite
clear when it comes to machine transforms and not environment. It sounds
like it’s possible, but the naming scheme isn’t clear.

Kori Francis
Lead Software Developer
Clinical Support Systems, Inc.
Web: http://www.clincialsupportsystems.com

Hi,

I will look at getting the documentation updated to be a bit clearer.
If you have web.ENVIRONMENTNAME.config it will transfer that on the corresponding environment.
So in your case it should just be web.Acceptance.config and web.Production.config

Vanessa

Vanessa,

That’s the opposite of what I’m talking about. I know that it’s easy to do
environment configs (like you’ve just specified), but I need
machine-specific config transforms. The issue I’m having is this, on one
deploy - I need to clear any existing rules and add one rewrite rule that
forwards all root requests to the signin page. I haven’t been successful in
using any combination of powershell, but it’s a super simple config
transform. What I am looking for is to include something like
web.MACHINENAME.config that will only be run when deploying to MACHINENAME.
Is that possible? Seems like it is, but it’s not clear - that’s where I’m
looking for clarification.

Kori Francis
Lead Software Developer
Clinical Support Systems, Inc.
Web: http://www.clincialsupportsystems.com

Hi Kori,

Thanks that extra information, it really helped to understand what you are after.
So a couple of things 1. you will need a copy of Octopus that is 2.5.11 as this was when the variable was added and 2. under additional transformations this should work (see screenshot).

Hope this helps!
Vanessa

Perfect! Thanks.