Automatically applying existing config transforms

We are moving an existing MVC project that we historically deployed using WebDeploy (Publish) in Visual Studio. There are several different config transforms setup for different environments.

I’m having difficulty understanding how to setup Octopus to apply these transforms, dependent on which environment the release is being made to.

I’ve read the help available at http://docs.octopusdeploy.com/display/OD/Configuration+files along with reading posts like https://github.com/OctopusDeploy/Issues/issues/1037, but I’ve not yet had success.

I’ve tried:

  • Within the deployment step, enabling the ‘‘Configuration variables’’ option
  • Within the deployment step, enabling the ‘‘XML transforms’’ option, along with include a custom variable #{ConfigTransform} which is set to the configuration transform per environment.
  • Ensuring that the Octopus Deploy environment name (Internal, staging, production) match the name of the config transforms (Web.Internal.config etc…)

I would very much appreciate some assistance.

Thanks
Peter

I forgot to mention in my initial post…

From looking at the Octopus Deploy log I can see that on a deployment to our Internal environment that the Web.Release.config is being applied, but no other transforms.

Ideally I’d like the Web.Release.config to not be applied and only the config transform file that is being explicitly stated.

Hi Peter,

Thanks for getting in touch! If you would like Web.Release.config not transformed do not use the “Configuration Variables” option.
instead use the “Additional Transforms” option and add the following:
Web.#{Octopus.Environment.Name}.config => Web.Config
Then name your environmental transforms Web.Internal.config, Web.staging.config etc

If this doesn’t work a screenshot of those files in a package browser, and a screenshot of the setup in the step will help us get to the bottom of this.

Let me know how that goes!
Vanessa

Hello Vanessa

Thanks for your response.

I’ve tried what you’ve suggested, but unfortunately I’m still experiencing problems.

I have now hard coded the transform to Web.Debug.config => Web.config (as shown in the Deploy step.PNG). This transform does seem to get applied, however then the Web.Release.config is then being applied and an exception is thrown (Shown in Publish log.png).

I’ve also attached NuGet package.PNG which shows the files inside the package being deployed.

Thanks
Peter

Hi Peter,

So what I would like you to try is to remove the “configuration variables” from your features completely, and un-tick “automatically run configuration transform files”.
This will stop your Web.Release.config from running, and the others will run based on the rules you provide.
As it is throwing those errors it is then not getting to your rules.

Vanessa

Thank you Vanessa - It’s working as expected now and I understand how these configuration points are being carried out.

Part of my confusion was thinking that the Automatically run configuration transformation files needed to be ticked in order for the additional transforms to be applied.

I appreciate you explaining how to use this part of Octopus and I’m happy to close this call.

Thanks
Peter

Hi Vanessa,

I am also doing configuration transforms and i have tried the workarounds mentioned in this thread. but the transforms are not working.

I have made sure of the following:

Included my Web.[Environment].config
Unticked "Automatically run configuration transformation files " in the process
Added the following to additional transforms textarea: Web.BudgetPlanning_4530_Dev.config => Web.Config

But the transform doesnt work. Can you help?

Hi Carlos,

Thanks for getting in touch! So the first thing to confirm is that you are creating a new release with each change you make. If you have this covered can you provide the following:

  1. A screenshot of your package with the configuration files
  2. A screenshot of the configuration settings in your step
  3. A full deployment log: http://docs.octopusdeploy.com/display/OD/Get+the+raw+output+from+a+task

If you want to make another thread and make it private that is fine. Or you can email support at octopusdeploy dot com with this information.

This should give us a start at where this is going wrong.
Vanessa

Hi Vanessa,

I’m having the same experience as Carlos above, I’ve got all the things checked and removed as you suggested for Peter who started the thread, but for some reason it’s not working. I am constantly removing releases and making new ones too, also tried increasing version numbers but all without success.

In the raw log it seems it’s not even touching the xml transformation step.

I’ve got the information that you requested from Carlos attached

Some help would be most welcome!

Thanks.

Dirk

tasklog.txt (7 KB)

Hi Dirk,

I did notice that your filename was Web.config and your additional transform says Web.Config.
It might be a long shot, but I believe it is case sensitive - see if that helps?

Vanessa

Hi,

I have been trying to deploy web.configuration in QA and Stage environments.

I have the following config files in my .nupkg which has been deploying in environments

Web.config
Web.Debug.config
Web.Release.config
Web.QA.config
Web.Stage.config

I have added the below line in Additional transforms which get executed and successfully. but the Web.config does not get transfored from Web.QA.config and Web.Stage.config files

Web.#{Octopus.Environment.Name}.config => Web.config

Success: PreDeploy.ps1
08:52:58 Verbose | Running PowerShell script: E:\Octopus\Applications\Stage\MeetingRooms.Api\1.0.0.449_4\PreDeploy.ps1
|
| Success: Apply Web.Stage.Config
08:52:59 Info | Transforming ‘E:\Octopus\Applications\Stage\MeetingRooms.Api\1.0.0.449_4\Web.config’.
08:52:59 Verbose | Source file: ‘E:\Octopus\Applications\Stage\MeetingRooms.Api\1.0.0.449_4\Web.config’.
08:52:59 Verbose | Transform file: ‘E:\Octopus\Applications\Stage\MeetingRooms.Api\1.0.0.449_4\Web.Stage.Config’.
|
| Success: Copy files to E:\wwwroot\test-stage.meetingrooms.com
08:52:59 Info | Copying package contents to ‘E:\wwwroot\test-stage.meetingrooms.com

Any idea? Am I missing anithing here?

Thanks,
Pranav

is it possible to do some conditions within the Additional Transforms?

e.g. if(#{Octopus.Environment.Name} == “Alpha”)
Web.Prod.config => Web.Config

Basically need to inherit all changes from Prod but also modify it.

Hi Pranav,

Those logs show that the transform is being applied. What happens when you run both files through this form: https://webconfigtransformationtester.apphb.com/

Vanessa

Hi Stephen,

No I am sorry to say that you cannot use that syntax in that field. Would scoped variables work for you?
Web.#{MyEnvironmentConfig).config => Web.config
where MyEnvironmentConfig is defined as Prod but scoped only to Alpha?

Let me know what you think!
Vanessa