FsUnit: cannot check portable library because of it and test a project with different versions of F # .Core

I have a portable library for which the version of FSharp.Core 3.7.4.0 . Installation (in the Unit Test project) FsUnit installs version 3.1.2.5 as a dependency of 3.1.2.5 .

In this regard, using the portable library functions in my Unit Test project, for example:

 module StammaTests.PieceTests open Stamma open NUnit.Framework open FsUnitTyped [<Test>] let ``Testing a Basic function`` () = Piece.toChar Black King |> shouldEqual 'k' 

gives an error:

Result message: System.IO.FileLoadException: Failed to load file or assembly "FSharp.Core, Version = 3.7.4.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a 'or one of its dependencies. The installed assembly manifest definition does not match the Help assembly. ( Exception from HRESULT: 0x80131040)

I tried to upgrade the version of FSharp.Core from NuGet to 4.0.0.1 (even checking both projects when updating), and now even something simple:

 [<Test>] let ``Testing the test`` () = 1 |> shouldEqual 1 

not working giving this similar error.

Result message: System.IO.FileLoadException: Failed to load file or assembly "FSharp.Core, Version = 4.3.1.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a 'or one of its dependencies. The installed definition of the assembly manifest does not match the Help assembly. ( Exception from HRESULT: 0x80131040)

And the error for the first failure test does not change.

I feel that I am missing something painfully obvious, and I found several people with similar problems, but I don’t understand what they did to solve it (they all seemed to solve it.) For example this one .

Edit

Both projects are libraries, and I don't have an app.config file to add anything.

0
source share
2 answers

I found a solution that actually worked here

Basically, add App.config to the test project and write the following:

 <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-4.3.1.0" newVersion="4.3.1.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.6.4.14350" newVersion="2.6.4.14350" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> 

It adds a binding to Fsharp.Core and NUnit.Framework , unlike regular solutions in which you add a binding only for Fsharp.Core .

0
source

Add the binding redirection to your app.config file to redirect all FSharp.Core bindings to your desired version. For example, to use version 4.4.0, your app.config file would look something like this:

 <?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-4.4.0.0" newVersion="4.4.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> 
+1
source

Source: https://habr.com/ru/post/1014347/


All Articles