Search code examples
web-configoctopus-deployweb.config-transform

Octopus deployment transformation


Was looking at the following page

http://docs.octopusdeploy.com/display/OD/Substitute+Variables+in+Files

And noticed that you can use variables. I have set some variables up and my site deploys fine into my test environment, but now I cannot run my site locally within the development environment. The IDE complains about the variables in the sites web.config file. Should the variables be set in the web.test.config and not the web.config file?


Solution

  • If you want to substitute variables in your config files, you don't need to use tokens. The tokens are used for non-configuration files.

    For example, if I have the following app setting in my config file (set to false for development).

    <appSettings>
        <!-- Octopus:OptimizeBundlesEnabled -->
        <add key="OptimizeBundlesEnabled" value="false" />
    </appSettings>
    

    When I define a variable in my Octopus Deploy project named OptimizeBundlesEnabled with a value of true - the value after deployment will be true.

    So you don't need to change your config to this (which would indeed cause problems when you run locally):

    <add key="OptimizeBundlesEnabled" value="#{OptimizeBundlesEnabled}" />
    

    The tokenised version is useful for other file types, but config is done automatically by Octopus.