我想在我的 VS2010 部署项目中对 web.config 中一个元素的两个不同属性应用两个不同的转换。请考虑以下 web.config 片段:
<exampleElement attr1="false" attr2="false" attr3="true" attr4="~/" attr5="false">
<supportedLanguages>
<!-- Some more elements here -->
</supportedLanguages>
</exampleElement>
现在我如何在转换后的web.config中更改属性“attr1”并删除属性“attr5”?我知道如何执行单个转换:
<exampleElement attr1="true" xdt:Transform="SetAttributes(attr1)"></exampleElement>
并且:
<exampleElement xdt:Transform="RemoveAttributes(attr5)"></exampleElement>
但是我不知道如何将这些变换组合起来。有人可以帮忙吗?
编辑:
还不能回答自己的问题,但解决方案似乎是:
看起来可以通过以下方式重复使用同一个元素并应用不同的转换:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<exampleElement attr1="true" xdt:Transform="SetAttributes(attr1)"></exampleElement>
<exampleElement xdt:Transform="RemoveAttributes(attr5)"></exampleElement>
</configuration>
就像之前所说的,这似乎是有效的,但我不确定这是否是 web.config 转换语法的预期使用方式。