我们正在测试Octopus Deploy,因此我们制作了一个示例web.config文件,我们在不同的环境中安装和转换.web.config转换和使用自定义变量工作正常,但我无法获得内置的Octopus变量来替换.以下是web.config中XML部分的示例:
<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>
Run Code Online (Sandbox Code Playgroud)
这里的web.Dev.config,以环境命名:
<appSettings>
<add key="environmentTransform" value="Dev" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
这是结果:
<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" …Run Code Online (Sandbox Code Playgroud)