系统级bindingRedirect的F#4.0.0.0至4.3.0.0系统、bindingRedirect

2023-09-04 22:39:24 作者:你胸小不要说话。

我有哪些是失败的一些共同的xUnit测试

I have some xUnit tests which are failing with the common

Could not load file or assembly 'FSharp.Core, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. 
The system cannot find the file specified.

要进行全机的重定向,我添加到文件

To perform a machine-wide redirect, I added to the file

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config 

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a"
                        culture="neutral"/>
      <bindingRedirect oldVersion="4.0.0.0" newVersion="4.3.0.0"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

你有一个更好的办法来处理4.0 / 4.3的问题肯定?

Do you have a better way to deal with the 4.0 / 4.3 issue definitely ?

推荐答案

我不知道的xUnit,但如果你的单元测试运行支持的app.config文件,你可以在配置连接到单元测试组件(例如,一个沿着你得到一个默认的F#控制台应用程序模板)行的app.config。如果测试运行没有兑现的app.config,那么我想在machine.config策略是一个体面的。

I don't know xUnit, but if your unit test runner supports app.config files, you can just attach the config to the unit test assemblies (e.g. an app.config along the lines of what you get with a default F# console application template). If the test runner does not honor app.config, then I think the machine.config strategy is a decent one.