所以当有人将我的nuget包添加到他们的代码中时,我正在尝试替换dependentAssembly.
我想改变的程序集是:
<dependentAssembly>
<assemblyIdentity name="Common.Logging.Core" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
因此,我使用此xml文件并提供以下帮助:Web.config转换 - 缺少的手册
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly xdt:Transform="Replace" xdt:Locator="Condition(./_defaultNamespace:assemblyIdentity/@name:'Common.Logging.Core')">
<assemblyIdentity name="Common.Logging.Core" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="2.2.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但是我收到了错误:在项目中将转换应用于'web.config'时发生错误:'blabla'具有无效的限定名称.
注意到当我将"Replace"更改为"Remove"时,它会删除完整的dependentAssembly,但不知何故,它会再次将相同的dependentAssembly添加到web.config中.也许是因为在web.config转换后添加了Common.Logging.Core依赖项?
也许这就是替换不起作用的原因?