Add a Transform File as a variable

We’d like to do some web.config transforms but do NOT want to put in in the build. This is both for security and inability to update developer code. We would also rather not use config variables in this.
Basically, would love to have a transform file kept in octopus that is different per environment and have octo run it on the target. Is this possible?

Hi @zippo706,

Thanks for getting in touch. I think this is possible with a couple of approaches. Something like the following should work well.

  • Store your environment specific files as variables (Octopus doesn’t really support storing arbitrary files).
  • Turn on the Custom Deployment Scripts feature and add a pre-deployment script to save your variable to the a file next to the standard web.config (or another location that suits).
  • Ensure your step (I’m assuming it’s a Deploy to IIS step) also has Configuration Transforms turned on and configure it to apply the transform file you just saved.

This is obviously more work than using the built-in functionality but it gives you the control you want.


Another approach is add a script step to leverage Microsoft.Web.XmlTransform to apply the transformation to your web.config files using the variables. This is likely a lot more work though.

FYI - Our implementation of configuration transforms is open source and available on GitHub. You could review this and extract the logic into a command line too if it suits.


Hope this helps!

Thanks

Rob

Thanks Rob. At least i know.

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