使用 Visual Studio 发布我的 asp 核心项目时,.config
会在我的可执行文件旁边创建一个文件。
其中.config
包括几个bindingRedirect
这样的:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="6.0.0.0" newVersion="8.0.0.0" />
<bindingRedirect oldVersion="7.0.0.0" newVersion="8.0.0.0" />
<bindingRedirect oldVersion="6.0.0.0" newVersion="9.0.0.0" />
<bindingRedirect oldVersion="8.0.0.0" newVersion="9.0.0.0" />
<bindingRedirect oldVersion="7.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Serilog" publicKeyToken="24c2f752a8e58a10" culture="neutral" />
<bindingRedirect oldVersion="1.5.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.1.37.0" newVersion="1.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="1.2.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
在这里,我想将 for 更改bindingRedirect
为Newtonsoft.Json
:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
根据这篇博文:http: //blog.rytmis.net/2016/03/29/asp-net-core-and-assembly-binding-redirects/我应该能够在App.config
那里创建并指定绑定。但是,我无法让它工作。当我添加一个时,它仍然会产生相同的.config
.
有任何想法吗?
注意:我可以在我的项目中创建一个.config
与我的可执行文件同名且正确的文件bindingRedirect
,然后publishOptions
在我的project.json
文件中编辑以包含它。然后我必须手动添加所有其他的 future bindingredirect
。