2012-03-07 90 views
2

我已经在这里和谷歌(等)的类似帖子做了平常的检查,但无济于事。Web.Config转换XPath

基本上我有一个使用Web.Config转换的Visual Studio 2010 MVC3解决方案,并且大部分他们工作得很好。但是,我有一些单元测试绑定,我想删除它们,因为它们的XML位置,它们有点棘手。

这里是削减版本:

<?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-2.0.0.0" newVersion="3.0.0.0" /> 
      </dependentAssembly> 
      <dependentAssembly> 
       <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> 
       <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" /> 
      </dependentAssembly> 
      <dependentAssembly> 
       <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNETAdapter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
       <codeBase version="10.0.0.0" href="file:///C:/Program%20Files/Microsoft%20Visual%20Studio%2010.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNETAdapter.DLL" /> 
      </dependentAssembly> 
      <dependentAssembly> 
       <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
       <codeBase version="10.0.0.0" href="file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.QualityTools.Common/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.QualityTools.Common.dll" /> 
      </dependentAssembly> 
      <dependentAssembly> 
       <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.ExecutionCommon" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
       <codeBase version="10.0.0.0" href="file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.QualityTools.ExecutionCommon/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.QualityTools.ExecutionCommon.dll" /> 
      </dependentAssembly> 
      <dependentAssembly> 
       <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Resource" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
       <codeBase version="10.0.0.0" href="file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualStudio.QualityTools.Resource/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.QualityTools.Resource.dll" /> 
      </dependentAssembly> 
      <dependentAssembly> 
       <assemblyIdentity name="AjaxMin" publicKeyToken="21ef50ce11b5d80f" culture="neutral" /> 
       <bindingRedirect oldVersion="0.0.0.0-4.46.4422.26284" newVersion="4.46.4422.26284" /> 
      </dependentAssembly> 
     </assemblyBinding> 
    </runtime> 
</configuration> 

Esentially我想删除包含与包含“Microsoft.VisualStudio”名称的子节点的节点。

到目前为止,我可以得到节点改造我的Web.Config中使用一些详细的语法为空:

<?xml version="1.0" encoding="utf-8"?> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <runtime> 
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
      <dependentAssembly> 
       <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNETAdapter" xdt:Transform="Remove" xdt:Locator="Match(name)" /> 
       <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Common" xdt:Transform="Remove" xdt:Locator="Match(name)" /> 
       <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.ExecutionCommon" xdt:Transform="Remove" xdt:Locator="Match(name)" /> 
       <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Resource" xdt:Transform="Remove" xdt:Locator="Match(name)" /> 
       <codeBase version="10.0.0.0" xdt:Transform="RemoveAll" xdt:Locator="Match(version)" /> 
      </dependentAssembly> 
      <dependentAssembly xdt:Locator="XPath(//runtime/*/*[not(node())])" xdt:Transform="RemoveAll" /> 
     </assemblyBinding> 
    </runtime> 
</configuration> 

这类作品,但给了我,我不想空节点。

任何想法?

干杯!

+1

没有人对此问题有任何建议吗? – Jimmy 2012-03-15 10:29:59

回答

3

这是我已经删除了不必要的dependentAssembly引用,不知道这是否是最好的方式,但它为我工作:

在Web.config中

,名称添加到所有不属于dependentAssembly项生产所需,我选择使用“QualityTools”。

<dependentAssembly name="QualityTools"> 
    <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNETAdapter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
    <codeBase version="10.0.0.0" href="file:///C:/Program%20Files/Microsoft%20Visual%20Studio%2010.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNETAdapter.DLL" /> 
    </dependentAssembly> 
    <dependentAssembly name="QualityTools"> 
    <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
    <codeBase version="10.0.0.0" href="file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.QualityTools.Common/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.QualityTools.Common.dll" /> 
    </dependentAssembly> 
    <dependentAssembly name="QualityTools"> 
    <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.ExecutionCommon" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
    <codeBase version="10.0.0.0" href="file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.QualityTools.ExecutionCommon/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.QualityTools.ExecutionCommon.dll" /> 
    </dependentAssembly> 
    <dependentAssembly name="QualityTools"> 
    <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.Resource" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
    <codeBase version="10.0.0.0" href="file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualStudio.QualityTools.Resource/10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.QualityTools.Resource.dll" /> 
    </dependentAssembly> 

在你转换文件,添加一个变换到名为“QualityTools”

<runtime> 
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly name="QualityTools" xdt:Locator="Match(name)" xdt:Transform="RemoveAll" /> 
</assemblyBinding> 

注意变换的removeAll删除所有条目,删除与该名称的所有条目。