Msbuild Web.config转换-周围元素
我正在使用VS2010提供的web.config转换。在这种情况下,我想知道在转换过程中是否可以用另一个元素“包围”一个元素。以下是一个例子: 默认web.config包含:Msbuild Web.config转换-周围元素,msbuild,web-config,web-config-transform,Msbuild,Web Config,Web Config Transform,我正在使用VS2010提供的web.config转换。在这种情况下,我想知道在转换过程中是否可以用另一个元素“包围”一个元素。以下是一个例子: 默认web.config包含: <configuration> <system.web> .... </system.web> </configuration> .... 我的转换文件应该包含 <configuration> <location inheritInC
<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,closing location元素不是有效的xml(我猜是因为Transform属性)。仅仅在system.web之前插入一个自动关闭的位置元素也没有帮助,因为生成的system.web仍然没有被“包围” 目前,使用web.config转换无法实现这一点,但如果您编写一个自定义转换,它确实应该是可行的。。。有一个关于如何编写自定义转换的文档更新正在进行中,但现在还没有发布
我会尽快发布它,因为它是可用的 如果在您的网络配置中添加一个空的位置标记,它将不起作用 然后,您可以将该文件放在变换文件中与另一个文件相同的位置:
<location xdt:Locator="XPath(some xpath expression)"
inheritChildApplications="false"
xdt:Transform="SetAttributes(inheritChildApplications)">
还有收尾标签等等。有没有想过?我目前正在研究这个确切的情况。