I want to replace variables inside web.config file with variables defined in Octopus project. I am using Octopus Cloud and Structured configuration variables for variable replacement. Below is the log output.
Performing variable substitution on ‘C:\Octopus\Tentacle\Work\20210712090800-1719-32\Script.ps1’
July 12th 2021 19:10:52Verbose
The file at C:\Octopus\Tentacle\Work\20210712090800-1719-32\hf.website.develop\Website\Web.config does not match any known filename patterns. The file will be tried as multiple formats and will be treated as the first format that can be successfully parsed.
July 12th 2021 19:10:52Verbose
Attempting structured variable replacement on file C:\Octopus\Tentacle\Work\20210712090800-1719-32\hf.website.develop\Website\Web.config with format Json
July 12th 2021 19:10:52Verbose
The file at C:\Octopus\Tentacle\Work\20210712090800-1719-32\hf.website.develop\Website\Web.config couldn’t be parsed as Json: Unexpected character encountered while parsing value: <. Path ‘’, line 0, position 0.
July 12th 2021 19:10:52Verbose
Attempting structured variable replacement on file C:\Octopus\Tentacle\Work\20210712090800-1719-32\hf.website.develop\Website\Web.config with format Xml
July 12th 2021 19:10:52Info
No structures have been found that match variable names, so no structured variable replacements have been applied.
July 12th 2021 19:10:52Info
Structured variable replacement succeeded on file C:\Octopus\Tentacle\Work\20210712090800-1719-32\hf.website.develop\Website\Web.config with format Xml
July 12th 2021 19:10:52Verbose
Executing ‘C:\Octopus\Tentacle\Work\20210712090800-1719-32\Script.ps1’
Below is my web.config file
<?xml version="1.0" encoding="utf-8"?>Variable get replaced with
/configuration/appSettings/add[@key=‘centralApiBaseUrl’]/@value → My_Value
but not with
centralApiBaseUrl → My_Value
Which is correct way to define the variables in Octopus project?
Variable replacement happens with .NET Configuration Variables option but Octopus scans for all .config files before it does replacement.