Substitute Variables in Files - but substitute appSettings etc?

Hi,

We have some older appsettings that are badly named / misspelled etc. So we would like to have them corrected in Octopus (where partners and such look). But it seems that the “Substitute Variables in Files” feature specifically ignores connectionStrings and appSettings. Is that true? Or am I somehow making another mistake?

E.g. I have this:

<appSettings>
    <add key="APPIURL" value="#{ApiURL}" />
</appSettings>

But it is not replaced by the above feature?
(Of course, the “ApiURL” variable exists and can be echoed out in the same process step)

/Werner

Hi Werner,

We actually automatically replace appSettings, applicationSettings, and connectionStrings. The following page has the rundown of what we do here.
https://octopus.com/docs/deploying-applications/configuration-files

So where you have something like the following as a default:

<configuration>
  <appSettings>
    <add key="APPIURL" value="apiurl"/>
  </appSettings>

You can create the variables APPIURL and API-XXXXXXXXXXXX. The Tentacle will automatically replace the values without having to call #{ApiURL}.

Let me know if that helps or if you have further questions here. :slight_smile:

Best regards,
Daniel

Hi Daniel,

Well yes I know, but the idea was that I don’t want a variable called “APPIURL” in Octopus. But as I understand you, the feature “Substitute Variables in Files” by design does in fact exclude appSettings for example?

Or put in another way, is it by design that “Substitute Variables in Files” running on a config with this content:

<appSettings>
    <add key="APPIURL" value="#{ApiURL}" />
</appSettings>

doesn’t substitute “#{ApiURL}” ?

Hi Werner,

Sorry for my previous, rather generic answer. I just tested this on my end, and it looks like it worked. I created a variable #{ApiURL} in my web.config’s + and targeted my web.config with Substitute Variables in Files.

Could you please attach a full deployment log where this is happening, with variable output enabled?
https://octopus.com/docs/how-to/how-to-turn-on-variable-logging-and-export-the-task-log

Best regards,
Daniel

Hi Daniel,

Thanks - that got me going and I found out why it didn’t work. In the “Substitute Variables in Files” section I entered the full path the the CONFIG file in my “CustomInstallationDirectory”. But apparently the substitution is done in the octopus application folder (OriginalInstalledPath I think it is). So instead of an absolute path, I specified a relative one. And now it works…

One thing I noticed (not an issue, just a comment): When using the debugging variable prints: For “Configuration Variables” for example, Octopus prints out what variables are are set. But for “Substitute Variables in Files”, it does not.

Thanks for you help!

/Werner

Hi Werner,

Good to hear that you got it working! I’ll look into the substitute variable in files not showing. :slight_smile:

Best regards,
Daniel