使用 VSTS 发布定义替换列表中的多个变量

Substituting multiple variables in a list using a VSTS Release Definition

我目前在 VSTS 中使用变量替换,但是我在如何 select 列表中的特定元素方面遇到了障碍。

我必须提供要替换的变量的名称和用于替换旧值的键。我可以在配置中使用 . 到 select 嵌套元素。

我有以下 app.config.

<services>
  <service behaviorConfiguration="ServiceBehaviour" name="Application.Project01">
    <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="web" contract="Application.Interface01">
      <identity>
        <dns value="dns01" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/Project01/" />
      </baseAddresses>
    </host>
  </service>
  <service behaviorConfiguration="ServiceBehaviour" name="Application.Project02">
    <endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="web" contract="Application.Interface02">
      <identity>
        <dns value="dns01" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/Project02/" />
      </baseAddresses>
    </host>
  </service>
</services>

我希望能够单独替换这些服务中的每一个中的变量。我感兴趣的具体键是 services.service.endpoint.identity.dns.valueservices.host.baseaddresses.add.baseaddress.

我尝试了以下方法来编辑 dns 值

我正在使用的任务是 Azure App Service Deploy 版本 3。*

对于Azure App Service Deploy任务的XML variable substitution特性,仅对配置文件的applicationSettings、appSettings、connectionStrings和configSections元素生效。

所以你不能用它来达到你的要求。

你可以尝试XML转换。

您也可以将它与其他任务一起尝试,例如 Release Management Utility tasks or others