在VSTS版本管理中替换WCF端点地址

时间:2018-06-07 21:23:17

标签: continuous-integration azure-devops release-management

我正在使用VSTS构建和部署Windows服务到几个不同的服务器。在我的Windows服务的App.config中,我有一个我正在调用的WCF服务的引用:

<system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="WSHttpBinding_IMobileSyncService">
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="None" />
        <message clientCredentialType="UserName" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="https://192.111.11.111/1.0.0.18/MobileService.svc"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMobileService"
    contract="MSSRef.IMobileService" name="WSHttpBinding_IMobileService" />
</client>

我目前正在为所有服务器使用相同的Build,但使用VSTS的Release Management阶段替换App.config中的值(例如,连接字符串和服务器特定值)。这很完美。

但是,参考上面的代码示例,如何将endpoint address替换为每个服务器特定的值?我不确定如何在配置文件中定位此特定块。

1 个答案:

答案 0 :(得分:-1)

有一些扩展可以做到,例如:

Release Management Utility tasks,相关文章:Using Tokenization (Token Replacement) for Builds/Releases in vNext/TFS 2015

Replace Tokens

您也可以通过PowerShell进行编程。