Variable Substitution in Files Not Working

Hi there,

I am trying to get Octopus to substitute a variable in my Web.config at deployment time after the Web.config has been transformed.

So, in my Web.config, I have:

<endpoint address="#{PolicyServiceEndpointAddress}" binding="basicHttpBinding" bindingConfiguration="Connect" contract="PolicyService.IPolicyService" name="PolicyServiceSoap11" />

And I have a Project Variable named PolicyServiceEndpointAddress with a value of the address that I want to set the endpoint to.

In my Process, I have included the step ‘Substitute variables in files’ and included the Web.config in my list of Target files.

However, after deployment, the variable #{PolicyServiceEndpointAddress} is still present in the Web.config - it has not been substituted with the value that I want.

N.B. I do a transform on this Web.Config to ‘inject’ the Variable itself so the transform works but the substitution does not!

Thanks,

Sean

Just realised that I might try substituting the variables in the Web.Release.Config and see if that might work (as opposed to the transformed Web.Config)

Hi Sean,

Thanks for getting in touch! Performing the variable substitution on your Web.Release.config file is exactly what I would suggest. Did that get it working for you?

The reason it wasn’t working comes down to the feature ordering of package steps, where variable substitution is done before configuration transforms. You can refer to our docs which outlines the package step feature ordering.
https://octopus.com/docs/reference/package-deployment-feature-ordering

Let me know how you go and if you have any further questions.

Kind regards,

Kenny

Hi Kenny.

That was exactly it!

Sometimes it’s more straightforward when you put your thoughts down on paper (or, in this case HTML) and read them back to yourself.

So, putting the variables in the Web.Release.config works perfectly.

Thanks again for your help,

Sean

Hi Sean,

That’s great to hear it’s working as expected! Don’t hesitate to reach out if you have any further questions going forward. :slight_smile:

Kind regards,

Kenny