【发布时间】:2015-03-30 10:50:28
【问题描述】:
我的 Web 配置中有以下 XML,在发布模式下,我需要根据其子项的 name 属性删除dependentAssembly 部分:assemblyIdentity。我在这里尝试了答案:xdt transform locator that matches subnode content 但没有运气。 我的 web.config 是这样的:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Resource" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<codeBase version="10.0.0.0" href="file:///c:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2010.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNETAdapter.DLL" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
我已经在我的 web.release.config 中尝试了以下操作,以根据子元素选择第二个dependentAssembly 元素进行删除,但没有成功。
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" >
<dependentAssembly>
<!-- Attempt 1 -->
<assemblyIdentity xdt:Transform="RemoveAll"
xdt:Locator="Condition(@name='Microsoft.VisualStudio.QualityTools.Resource')"/>
</dependentAssembly>
</assemblyBinding>
<!-- Attempt 2 -->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly xdt:Transform="Remove"
xdt:Locator="Condition(assemblyIdentity/@name='Microsoft.VisualStudio.QualityTools.Resource')">
</dependentAssembly>
</assemblyBinding>
</runtime>
【问题讨论】:
-
webconfigtransformationtester.apphb.com 有助于降低转换。此外,您的dependentAssembly 名称与提供的配置以及定位器中的内容不匹配。
-
那是我在程序集名称上的错误,我编辑了帖子。谢谢你。您提供的网站很有帮助,但我仍然无法弄清楚
标签: web-config web-config-transform