因此,我开始使用nuget,它是web.config install/uninstall.xdt值。
我的问题是,是否存在和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, Version=4.5.4.0, Culture=neutral, 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>这是我的web.config在install.xtd之后
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="MyAssembly, Version=4.5.4.0, Culture=neutral, 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>有什么要去掉的标签吗?
发布于 2015-06-17 22:40:55
它显示您可以对一个元素指定多个转换。因此,您可以从安装中删除内容,然后检查元素是否有子元素,如果没有删除元素。
<?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, Version=4.5.4.0, Culture=neutral, PublicKeyToken=asdfasdfasdfasdf" />
</assemblies>
<assemblies xdt:Locator="Condition(count(*) = 0)" xdt:Transform="Remove"/>
</compilation>
</system.web>
</configuration>https://stackoverflow.com/questions/28592158
复制相似问题