【发布时间】:2012-02-15 02:07:48
【问题描述】:
从我的 VS2010 部署项目中,我想对 web.config 中一个元素的两个不同属性应用两种不同的转换。考虑以下 web.config sn-p:
<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 转换语法的预期用途。
【问题讨论】:
-
这是正确的,因为我一直在使用 XmlTransforms。我相信你已经回答了这个问题:)
标签: visual-studio-2010 msbuild web-config element transform