我正在使用通过 VS2010 提供的 web.config 转换。在这种情况下,我想知道在转换过程中是否可以用另一个元素“包围”一个元素。这是一个例子:
默认 web.config 包含:
<configuration>
<system.web>
....
</system.web>
</configuration>
我的转换文件应该包含
<configuration>
<location inheritInChildApplications="false">
<system.web>
...
</system.web>
</location>
</configuration>
所以基本上我想用 location 元素“包装” system.web 元素。我唯一的想法是做一个转换,以便我在之前和之后插入:
<location inheritInChildApplications="false"
xdt:Transform="InsertBefore(/configuration/system.web)">
</location xdt:Transform="InsertAfter(/configuration/system.web)">
但是根据VS,关闭位置元素不是有效的xml(我猜是因为Transform属性)。只是在 system.web 之前插入一个自动关闭的位置元素也无济于事,因为生成的 system.web 仍然没有被“包围”。