Custom Transforms Not In Project Root Folder

Hi there,

I’m wondering how the best way to go about setting values in custom .config files are?

I have values in a config/appSettings.config file and in a config/connectionStrings.config (relative to the project home directory) that I would like to change on a per-environment basis.

What is the best way to go about this?



Hi Sean,

Thanks for getting in touch! The best way to dynamically change your config values based on environment would be to define the values as project variables, you can then scope the variables to environments and call them inside the configuration file. If a variable is defined in the Octopus web portal, and an appSettings, applicationSettings or connectionStrings element exists for it in any of your .config files, Tentacle will automatically replace the value after extracting your package.

For example, you could have the following:

    <add name="#{DBConnectionString}" connectionString="#{ConnectionString}" />

Octopus will then replace them with the values in its project variables, based on the scoping of said variable.
The idea is to create multiple variables with the same name and assign all required values. You can then scope each variable to an environment. Our Scoping Variables page has some more information on this with some examples.

If you would like some information on performing transformations over multiple directories, we have an extensive blog post with many different examples for different scenarios that should give you some ideas.

Let me know if the above helps, or if you have any further questions. :slight_smile:

Best regards,