3
votes

The web.config in my nupkg file outputs the following:

<host>
          <baseAddresses>
            <add baseAddress="#{Url.AccountService}"/>
          </baseAddresses>
        </host>

According to Octopus' documentation on Substitute variables in files, the syntax above should be ok as long as I have the variable defined in my project. Which, I do.

enter image description here

I'm also deploying this package only to the DEV environment at this time.

enter image description here

Also, in the Deploy Website step, Under Substitute Variables in Files > I have web.config added to the list of files to perform the substitution on.

However, when the deployment goes through, octopus doesn't substitute this variable with the intended value. What am I doing wrong?

1
Your usage of the variable in the web.config looks correct. Your declaration of the variable in Octopus Deploy (Project Variables UI) looks correct. Listing 'web.config' in the section Substitute Variables in Files is also sufficient (albeit in our systems we use *.config). One thing that stood out immediately is the usage of the dot in Uri.AccountService. Have you tried to remove the dot and see substitution occurs? We do not use a 'dot' in our variable names, so I am uncertain if this syntax is allowed. If that doesn't work, try using *.config and see observe the outcome.Brien Foss
No, unfortunately, that didn't work.Ali Khakpouri
Is it possible the scope of your deployment is not DEV or PROD-BLUE?Brien Foss
It's DEV. I updated the question with the screenshot for your reference.Ali Khakpouri

1 Answers

3
votes

Per our conversation above and things you have tried. This is the only remaining idea I have for an answer for you:

The documentation Substitute Variables in Files states:

You need to state the full path of the file, relative to the installation directory. So, if you need to replace variables on a file called app.config that is inside of a configfolder on the root of your package, you need to put config\app.configon the Target files field.

It is possible that Octopus Deploy cannot find the file that you are stating requires variable substitution. Everything else about your examples and code looks correct.