We are testing Octopus Deploy, so we made a sample web.config file that we installed and transform in different environments. web.config transformation and use of custom variable work fine, but I can't get build-in Octopus variables to be substituted. Here's an example of of XML section in web.config:
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="environmentTransform" value="" />
<add key="EnvironmentVariable1" value="$OctopusEnvironmentName" />
<add key="EnvironmentVariable2" value="$(OctopusEnvironmentName)" />
<add key="EnvironmentVariable3" value="$(Octopus.Environment.Name)" />
<add key="EnvironmentVariable4" value="$Octopus.Environment.Name)" />
<add key="EnvironmentVariable5" value="$OctopusParameters["Octopus.Environment.Name"]" />
<add key="MachineVariable1" value="$Octopus.Machine.Name" />
<add key="MachineVariable2" value="#(Octopus.Machine.Name)" />
<add key="MachineVariable3" value="#OctopusMachineName" />
<add key="CustomVariable" value="CustomVariable" />
</appSettings>
And here's web.Dev.config, named after the environment:
<appSettings>
<add key="environmentTransform" value="Dev" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
</appSettings>
And here's the result:
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="environmentTransform" value="Dev" />
<add key="EnvironmentVariable1" value="$OctopusEnvironmentName" />
<add key="EnvironmentVariable2" value="$(OctopusEnvironmentName)" />
<add key="EnvironmentVariable3" value="$(Octopus.Environment.Name)" />
<add key="EnvironmentVariable4" value="$Octopus.Environment.Name)" />
<add key="EnvironmentVariable5" value="$OctopusParameters["Octopus.Environment.Name"]" />
<add key="MachineVariable1" value="$Octopus.Machine.Name" />
<add key="MachineVariable2" value="#(Octopus.Machine.Name)" />
<add key="MachineVariable3" value="#OctopusMachineName" />
<add key="CustomVariable" value="Value for maeaint01" />
</appSettings>
As you can see, Octopus variables are not replaced. Any idea why?