【发布时间】:2020-11-04 02:27:00
【问题描述】:
我有一个部署到多个环境的 Service Fabric 应用程序,每个环境都由一个复杂类型的 Application xml 元素定义。在这个 Application 元素中是一个参数列表,我想对这些参数应用 XDT 转换。
目标 xml 看起来像:
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/SimFabric" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="Parameter1" Value="" key="key1"/>
<Parameter Name="Parameter2" Value="" key="key2"/>
</Parameters>
</Application>
我要粘贴的 Web.*.config 采用以下形式:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<configSections>
<section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
</configSections>
<appSettings>
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="key1" value="value1" />
<add xdt:Transform="Replace" xdt:Locator="Match(key)" key="key2" value="value2" />
</appSettings>
</configuration>
XDT 转换可以用来将第二个文件中的值放在第一个文件中吗?
【问题讨论】: