因此,当有人将我的 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>
因此,我使用这个 xml 文件和帮助:Web.config transforms - the missing manual
<?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>
但我收到错误消息:将转换应用于项目中的“web.config”时发生错误:“blabla”的限定名称无效。
注意到当我将“替换”更改为“删除”时,它正在删除完整的dependentAssembly,但不知何故,它再次将相同的dependentAssembly 添加到 web.config 中。也许是因为在 web.config 转换之后添加了 Common.Logging.Core 依赖项?
也许这就是替换不起作用的原因?