Octopus Web.config转换客户端端点地址

时间:2017-03-27 18:57:10

标签: web-config octopus-deploy web.config-transform

我有一个Web项目,它使用位于客户端下的Web.config文件中的两个服务端点 - >端点 - >地址部分

我在章鱼变量部分找到了以下内容,但似乎找不到任何关于如何使用和实际变量来解决变化的参考

我正在使用webui for Octopus,这将是

的http:// {服务器名称} /应用程序#/项目/ {项目名称} /变量

variable-substitution-syntax

我尝试像这样分配变量,但值从未更新过 原始条目如下所示

<endpoint address="http://services-test.example.com/test.svc/soap" binding="basicHttpBinding" bindingConfiguration="soap" contract="test.service" name="soap" />

Name                    Address                         Instance   
Endpoint[A].Address     test-service-a.example.com      1
Endpoint[B].Address     test-service-b.example.com      2

使用八达通变量是否可以实现这一点? (我知道可以使用常规的Web.config Transforms来完成,因为我们已经这样做了)。

如果有可能,

的正确替换值是什么
  

端点地址

是,我将如何为多个不同的端点地址实现此目的?

1 个答案:

答案 0 :(得分:6)

听起来你大部分都在那里。如果它已经在使用您的Web.config转换,那么您需要做的就是使用变量替换标记替换转换中的值IN。

例如:Web.Release.Config

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.serviceModel>
    <client>
      <endpoint address="http://#{Server1}/test.svc/soap" name="x1"
                xdt:Locator="Match(name)" xdt:Transform="SetAttributes(address)" />
      <endpoint address="#{Endpoint2}" name="x2"
                xdt:Locator="Match(name)" xdt:Transform="SetAttributes(address)" />
    </client>
  </system.serviceModel>
</configuration>

当然这里有很多选择。

对于文件名,你可以坚持使用默认约定'Web.Release.config'或者使用'Web。[Environment] .config'或者使用自定义的东西。我们使用'Web.Octopus.Config',以便它不被任何其他进程接收。

  

有关命名转换的更多信息,请访问:https://octopus.com/docs/deploying-applications/configuration-files#Configurationfiles-Namingconfigurationtransformfiles

     

有关自定义转换的更多信息(Web.Octopus.com):https://octopus.com/docs/deploying-applications/configuration-files#Configurationfiles-AdditionalConfigurationTransforms

对于变量,您可以为服务器(name = x1)定义一个更简单的变量,或者只是将整个地址放在一个变量中,为Octopus提供更多控制(name = x2)。

关键部分是将变量替换标记放入配置中。 Octopus首先在配置文件上运行变量替换,然后运行变换。这意味着第一遍将替换Web.Release.Config中的标记,然后Octopus将对Web.config运行转换

希望有所帮助。

相关问题