Replace settings in SOME .config files with variables defined in Octopus

I am using Octopus Deploy 2.6.4.951 and have a Deploy NuGet Package step with the Configuration Variables feature enabled. Per the description for this feature, it will “Replace appSettings and connectionString entries in any .config files.” This is working properly for my app.config, but I’m getting a warning during deployment about another file named SomeFileName.config that Octopus Deploy is “Unable to update the config file - it may not be a valid XML file: Data at the root level is invalid. Line 1, position 1.” It is true that SomeFileName.config is not valid XML and, in fact, there is no substitution needed in this file.

Is there a way to tell Octopus Deploy to omit my SomeFileName.config file when trying to do apply Configuration Variables? If not, is there a way for me to tell Octopus Deploy on which files to run the Configuration Variables?

Hi Mball,

Thanks for getting in touch! The ‘Configuration Variable’ feature uses a convention that applies to all config files and this can’t be customised. The only way you could eliminate the warning is by turning off the Configuration Variables feature and use Configuration Transforms instead. This is a different approach and you do have to do the configuration up front but this is a once off.

Additional documentation: http://docs.octopusdeploy.com/display/OD/Configuration+files.

If you only want to transform your web.config, you would untick 'Replace appSettings and connectionString entries in any .config files’, untick ‘Automatically run configuration transformation files’ and specify the config file to transform in the additional transforms box.

For example, you could specific a single transform like the following.

Web.Release.Config => Web.config

Or use an environment specific variable.

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

Hope that helps!

Rob

Rob:

Thank you for your response. The configuration transforms do not meet my needs because many of the values to be substituted are sensitive and are stored in Octopus Deploy instead of my source control system.

I’ll stick with my homegrown solution for now, but would appreciate an “opt-in” list for files to have the Configuration Variables be processed.

Hi,

Thanks for the reply. I’d recommend you add that suggestion to our UserVoice site (https://octopusdeploy.uservoice.com) so it can be voted on by other Octopus customers. We actively work on feedback/suggestions so it’s great place to go.

Hope this helps!

Rob

Hi,

Just a follow-up. This is an important issue so I’ve created a GitHub issue to add an ignore errors variable for Config variable replacement. This is slightly different than an opt-in list however it should fix your issue and it’s consistent with a similar variable for Config transforms. It should be fixed fairly soon as it’s marked as a priority. You can follow it’s progress here: https://github.com/OctopusDeploy/Issues/issues/1897

Hope this helps!

Rob