
我的问题是,是否存在xdt:transform将清除空元素.我在这里找不到任何东西.
https://msdn.microsoft.com/en-us/library/dd465326%28v=vs.110%29.aspx
这是我的例子.
我当前的Web.config.install.xdt看起来像这样
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-document-transform"> <system.web> <compilation xdt:transform="InsertIfMissing"> <assemblIEs xdt:transform="InsertIfMissing"> <add xdt:transform="InsertIfMissing" xdt:Locator="Match(assembly)" assembly="MyAssembly,Version=4.5.4.0,Culture=neutral,PublicKeyToken=asdfasdfasdfasdf" /> </assemblIEs> </compilation> </system.web></configuration>
我的卸载看起来像这样
<?xml version="1.0"?><configuration xmlns:xdt="http://schemas.microsoft.com/XML-document-transform"> <system.web> <compilation> <assemblIEs> <add xdt:transform="Remove" xdt:Locator="Match(assembly)" assembly="MyAssembly,PublicKeyToken=asdfasdfasdfasdf" /> </assemblIEs> </compilation> </system.web></configuration>
这是我的web.config之前(简化)
<system.web> <authentication mode="None" /> <compilation deBUG="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web>
这是install.xtd之后的web.config
<system.web> <authentication mode="None" /> <compilation deBUG="true" targetFramework="4.5"> <assemblIEs> <add assembly="MyAssembly,PublicKeyToken=asdfasdfasdfasdf" /> </assemblIEs> </compilation> <httpRuntime targetFramework="4.5" /> </system.web>
这是卸载后的web.config
<system.web> <authentication mode="None" /> <compilation deBUG="true" targetFramework="4.5"> <assemblIEs> </assemblIEs> </compilation> <httpRuntime targetFramework="4.5" /> </system.web>
反正有没有摆脱标签?
解决方法 您似乎可以在元素上指定多个转换.因此,您可以从安装中删除内容,然后检查该元素是否具有子元素,如果不是,则删除该元素.<?xml version="1.0"?><configuration xmlns:xdt="http://schemas.microsoft.com/XML-document-transform"> <system.web> <compilation> <assemblIEs> <add xdt:transform="Remove" xdt:Locator="Match(assembly)" assembly="MyAssembly,PublicKeyToken=asdfasdfasdfasdf" /> </assemblIEs> <assemblIEs xdt:Locator="Condition(count(*) = 0)" xdt:transform="Remove"/> </compilation> </system.web></configuration>总结
以上是内存溢出为你收集整理的c# – 如果没有子节点,则清除xdt元素全部内容,希望文章能够帮你解决c# – 如果没有子节点,则清除xdt元素所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)