I'd like to reference variables I've defined in my deployment project (scoped to an environment) from my web.config.[environment] transform files. When I do, the variable references end up in the transformed web.config without being replaced.
I eventually figured this out, through trial and error, so I'll share my experience here. If you want to substitute variables in configuration files at deploy time, you can do it with the current (>= 2.4.*) version of Octopus Deploy. Here are the steps I used when configuring the deployment step:
Click "Configure features" and turn on the "Substitute variables in files" option.
In the "Substitute variables in files" section that this adds, specify your target files. For me, this was "Web.#{Octopus.Environment.Name}.config". You don't have to specify a relative path, Octopus will find them wherever they are in your source tree.
That should do it. It would be nice if these configuration options were visually grouped in the user interface so that it was more obvious that they were dependent on one another.
This changes from Octopus 2.3 to 2.4. Variable substitution is now performed before XML transforms are run. See here for more details: https://github.com/OctopusDeploy/Issues/issues/827
© 2022 - 2024 — McMap. All rights reserved.