Variables not being applied to config on Deploy

I’m deploying a package that has 4 variables but only 1 of them is being applied to all the config files:

The following variables are available:

  • [DevInstanceNumber] = ‘3’
  • [DevEnvironmentNumber] = ‘1’
  • [DevDbInstance] = ‘ProductionMirror’
  • [OctopusPackageDirectoryPath] = ‘D:\Inetpub\Dev1\app0.dev.test.com
  • [RipApplicationId] = '00000000-0000-0000-0000-000000000000’
    Tasks will be run in the following order:
  • PowerShellPreDeployScript
  • CopyPackage
  • XmlConfigTransforms
  • XmlConfigVariables
  • PowerShellDeployScript
  • IisWebSite
  • DeletePackageFile
  • PowerShellPostDeployScript
    Looking for PowerShell scripts named PreDeploy.ps1
    No scripts with a .ps1 extension were found.
    Extracting package contents to 'D:\Inetpub\Dev1\app0.dev.test.com
    Updating any .config files
    Scanning configuration file: D:\Inetpub\Dev1\app0.dev.test.com\Web.config
    Setting //appSettings/add[@key=‘ApplicationId’] to '00000000-0000-0000-0000-000000000000’
    Scanning configuration file: D:\Inetpub\Dev1\app0.dev.test.com\web.dev.uk.config
    Setting //appSettings/add[@key=‘ApplicationId’] to '00000000-0000-0000-0000-000000000000’
    Scanning configuration file: D:\Inetpub\Dev1\app0.dev.test.com\web.dev.us.config
    Setting //appSettings/add[@key=‘ApplicationId’] to '00000000-0000-0000-0000-000000000000’
    Looking for PowerShell scripts named Deploy.ps1

Thanks,

Bill

Hi Bill,

Can you upload a copy of the .config files? (feel free to delete anything sensitive)

(You can mark this conversation as private if you like too)

Paul

Hi Bill,

The settings aren’t replaced inside the value - they are only replaced if the key matches. For example, this would work:

<add key="DevEnvironmentNumber" value="3" />
<add key="DevDbInstance" value="3" />

Octopus would update the value attributes of those elements based on the keys matching.

For a more complicated replacement, you would need to use a Deploy.ps1 PowerShell script to load the XML file and replace the contents.

Hope that helps,

Paul

I’ve edited the application settings to show how our current deployment solution handles variables. (Straight find/replace scan of a file.)

Is this something that you would be interested in supporting?

Telling my DEV team to re-write code in every application to support a deployment solution is going to be a deal breaker.

Thanks,
Bill