我想xdt:Transform
在Debug
配置中执行一次,但前提是条目的值app.debug.config
是某个值,让我们说true
保持简单。例如:
应用程序配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="Value.First" value="foo" />
<add key="Value.Second" value="foo" />
<add key="Value.Third" value="foo" />
</appSettings>
</configuration>
应用程序调试配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<!--Convenient flag to indicate if transform should happen-->
<add key="Perform.Transform.If.True" value="true" xdt:Transform="Insert" />
<!--Should only happen if the above is true-->
<add key="Value.First" value="bar" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
<add key="Value.Second" value="bar" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
<add key="Value.Third" value="bar" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
</appSettings>
</configuration>
我希望Value.*
app.config 中的所有条目仅在密钥Perform.Transform.If.True
设置为true
. 如果是false
什么都不应该发生。原因是有时在测试期间我们想快速打开和关闭由配置文件控制的东西。
我已经看到了Locator
诸如 Match、Conditional、XPath 等的选项,但似乎没有一个允许来自另一个条目的条件。可以用 slowcheetah/xdt 转换来完成吗?