Variable replacement not working on appsettings.json


I am doing a POC to migrate from our current choco nightmare, but obviously don’t want to change our packages yet. With that in mind our nuget packages contain various scripts and a zip file which contains all the artifacts for our package.


  • Tools
    • Deploy.ps1
    • Install.ps1


The app I am looking at is a windows service built with topshelf and I am using an offline package drop deployment. I have also created a tenant and associated the tenant with this project. The project has a variable template modelling the appsettings.json and I’ve populate the values for my tenant.

I’m using the windows service step template, and have a custom pre deploy script in it to unzip the contents of to the route with the following command:

expand-archive -path .\tools\ -destinationpath .\

This works fine and I get all the files where I expect them to be in the package folder and in the install directory I’ve set.

The problem I am having is the variable replacement is not happening. I’ve also tried manually manipulating the package so my appsettings.json is in the route to begin with, to rule out the json variable replacement happening too soon in the process.

I’ve tried various patterns and fixed paths to the appsettings from just appsettings.json to wildcards like **\appsetings.json, to full paths of both the package directory and install directory, to no avail.

Can you help?

Many thanks


Hi Andy,

Thanks for getting in touch. Can I check which feature you are using to do the variable substitution? There are two, JSON Configuraiton Variables and Substitute Variables in Files.

The path setup will be similar for both, **\appsettings.json should do what you want. You should also see a line in the task log indicating which files have had substitution applied.

The reason I ask about which feature though is that the replace behaviour is quite different. The first is designed to traverse the Json hierarchy and set the value, and your project variable name needs to be something like weatherApi:url. See here for more details.

If you use the substitute in files feature instead, then the you can use the standard #{} Octopus variables in the file and they will be replaced.


Hi Shannon,

I am using the JSON Configuration Variables with my project template variables set as parent:child as per the documentation.

I’ve then set the tenant specific variable values on the tenant for that particular project.

Many thanks


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.