Bre*_*ias 7 deployment xslt xpath web-config visual-studio-2010
你可以在这里和那里阅读web.config转换文档,但是有两个白象似乎没有人在讨论:
Condition或XPath改造,并...Locator被有意义嵌套在Transform?让我举一个可以从这两个选项中受益的例子.假设我有这个:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
假设我想完全擦除dependentAssembly与xpath匹配的节点及其子节点//runtime/assemblyBinding/dependentAssembly[assemblyIdentity@name='System.Web.Mvc'].要做到这一点,我可能想要这样的事情:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity
name="System.Web.Mvc"
xdt:Remove
xdt:Locator="Condition(..[*@name=$name])"
/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
很明显,我@name=$name根据xpath变量概念编写了语法,但这个例子说明了为什么我想要这个功能.这支持吗?我该如何调整语法以利用它?我可以输入一个字符串文字,但我只是想知道这是否可行.
我可能尝试删除dependentAssembly节点的另一种方法是:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" xdt:Transform="Remove">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" xdt:Locator="Match(name)" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
请注意,Transform它位于祖父节点上,定位器位于叶节点上.以上是合法的吗?我们的想法是仅删除dependantAssembly具有内部定位符匹配的节点.
除了这两种方法之外,您将如何删除目标dependantAssembly及其所有子节点?
小智 8
问题是assemblyBinding标记上的namespace属性.
删除AspNetHelper参考对我有用:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly xdt:Transform="Remove"
xdt:Locator="Condition(./_defaultNamespace:assemblyIdentity/@name='Microsoft.VisualStudio.Enterprise.AspNetHelper')">
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
@Thommy的解决方案对我有用,@ LifeintheGrid的解决方案使用了我想删除的实际程序集,因此我将两者结合起来并简化为:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly xdt:Transform="RemoveAll"
xdt:Locator="Condition(starts-with(./_defaultNamespace:assemblyIdentity/@name,'Microsoft.VisualStudio.QualityTools'))">
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3154 次 |
| 最近记录: |