How to handle Web.*.config transform in Octopus Deploy when the config has duplicate keys

Hello OD Team!

I’m having an issue attempting to transform a Web.config file using a Web.Release.config file when the Web.config file has two different applicationSettings configuration blocks that have a key with the same name.

I’ve written up the following StackOverflow question with more details. https://stackoverflow.com/questions/49162815/how-to-handle-web-config-transform-in-octopus-deploy-when-the-config-has-dupli

Any guidance on how to handle this type of scenario?

Thanks,
Alex

Hi Alex,

Thanks for getting in touch! This is an interesting question that I actually haven’t come across before! Transforming two different configuration blocks with the same name will probably be tricky, and my first thought was to try to avoid it if possible. However, I can think of a few possible solutions to handle this.

  1. You can substitute Octopus variable values into one of the blocks using the syntax #{Variable} in your config file, and define the file name in the Substitute Variables in Files feature in your package step. However, your config file would have #{Variable} written into it, so it wouldn’t work locally. You can refer to our documentation page on this feature.
    https://octopus.com/docs/deployment-process/configuration-files/substitute-variables-in-files

  2. Manually modify the XML yourself after deployment.

  3. Use another transform type like SetAttributes. You can find additional information on the transform types available on Microsoft’s documentation.
    https://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx?f=255&MSPPError=-2147217396

I hope this helps get you going! Don’t hesitate to reach out if you have any further questions going forward. :slight_smile:

Kind regards,

Kenny

1 Like

Thanks for the detailed response Kenny!

This was super helpful. Every one of those ideas would work for our case.

Hi Alex,

You’re very welcome! I’m glad it helped. Don’t hesitate to reach out if you have any further questions going forward. :slight_smile:

Kind regards,

Kenny

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