F# FsUnit.xUnit FSharp.Core和xUnit.assert程序集绑定
我正在使用F#迈出第一步,并使用FsUnit.xUnit进行测试。 在Visual Studio 2017中,我建立了一个全新的F#项目,并添加了一个测试项目。 对于测试项目,我先获取numget FsUnit.xUnit 3.0.0,然后获取numget FsUnit.xUnit.Sample。 万事俱备。 然后测试以失败告终F# FsUnit.xUnit FSharp.Core和xUnit.assert程序集绑定,f#,nuget,xunit,fsunit,F#,Nuget,Xunit,Fsunit,我正在使用F#迈出第一步,并使用FsUnit.xUnit进行测试。 在Visual Studio 2017中,我建立了一个全新的F#项目,并添加了一个测试项目。 对于测试项目,我先获取numget FsUnit.xUnit 3.0.0,然后获取numget FsUnit.xUnit.Sample。 万事俱备。 然后测试以失败告终 System.IO.FileLoadException Could not load file or assembly 'FSharp.Core, Version=4.
System.IO.FileLoadException
Could not load file or assembly 'FSharp.Core, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at ApplicationLibraryTest.Tests.Given a LightBulb that has had its state set to true.when I ask whether it is On it answers true.()
在阅读之后,我添加了一个app.config
,带有
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="4.4.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
因此,我在app.config
中添加了另一个重定向,如下所示
<dependentAssembly>
<assemblyIdentity name="xunit.assert" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="2.2.0.0" />
</dependentAssembly>
测试项目详情:
目标F#运行时:4.4.1.0
目标框架:4.6.2
我做错了什么?这是一个配置问题,还是我缺少了阻止FsUnit.xUnit运行测试的东西?通常不需要手动添加绑定重定向。我认为NuGet应该自动添加它们。尝试删除绑定重定向并运行我已经尝试过了。但还是再试了一次。我删除了重定向,在测试项目中只留下一个空app.config。然后在包管理器控制台中,我向测试项目添加了BindingRedirect。app.config中没有任何更改。它仍然是空的。测试显然仍然失败。还尝试了帖子中的提示。将app.config放入
bin\debug
文件夹(我认为它所指的是执行文件夹?)。再一次,测试失败。似乎是一个nuget问题。我添加了一个nuget标记,因此这可能会得到更适当的关注。您可能还想尝试使用paket而不是nuget。
<dependentAssembly>
<assemblyIdentity name="xunit.assert" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="2.2.0.0" />
</dependentAssembly>
System.IO.FileLoadException
Could not load file or assembly 'xunit.assert, Version=2.2.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at ApplicationLibraryTest.Tests.Given a LightBulb that has had its state set to true.when I ask whether it is On it answers true.() in D:\git\ApplicationLibrary\ApplicationLibraryTest\FsUnitSample.fs:line 18
System.IO.FileLoadException
Could not load file or assembly 'xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)
Exception doesn't have a stacktrace