I am trying to set up a basic FAKE F # project that can run FsUnit, but I cannot figure out how to solve the Method not found: 'Void FsUnit.TopLevelOperators.should(Microsoft.FSharp.Core.FSharpFunc`2<!!0,!!1>, !!0, System.Object)'
errors Method not found: 'Void FsUnit.TopLevelOperators.should(Microsoft.FSharp.Core.FSharpFunc`2<!!0,!!1>, !!0, System.Object)'
.
I read the following posts, which seem to be related to each other, but I apparently still don't understand it:
I created a JunkTest
library JunkTest
with the following setup:
paket.dependencies
source https://www.nuget.org/api/v2 nuget FAKE nuget FSharp.Core nuget FsUnit nuget NUnit nuget NUnit.Console
paket.references
FSharp.Core FsUnit NUnit
JunkTest.fs
module JunkTest open FsUnit open NUnit.Framework [<Test>] let ``Example Test`` () = 1 |> should equal 1 // this does not work //Assert.That(1, Is.EqualTo(1)) // this works (NUnit)
build.fsx (corresponding part)
Target "Test" (fun _ -> !! (buildDir + "JunkTest.dll") |> NUnit3 (fun p -> {p with OutputDir = "TestResults" } ) )
Exit
I see that FSharp.Core.dll is copied from the local packages
directory: Copying file from "c:\Users\dangets\code\exercism\fsharp\dgt\packages\FSharp.Core\lib\net40\FSharp.Core.dll" to "c:\Users\dangets\code\exercism\fsharp\dgt\build\FSharp.Core.dll".
And executing nunit3-console: c:\Users\dangets\code\exercism\fsharp\dgt\packages\NUnit.ConsoleRunner\tools\nunit3-console.exe "--noheader" "--output=TestResults" "c:\Users\dangets\code\exercism\fsharp\dgt\build\JunkTest.dll"
I tried to add the app.config
file with the root directory of the test project as follows, but it does not seem to solve the problem (NOTE: I am not using Visual Studio - do I have to do something special for the project to include the app.config
file?):
<?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.3.1.0" newVersion="4.3.1.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
Any help is appreciated.
EDIT:. The solution was that I did not properly configure the app.config
file to be included in the assembly. All the answers that said βjust add this to your app.config
fileβ did not help me because VSCode does not automatically add it to the fsproj
file.
The part I added:
<None Include="App.config" />
In an ItemGroup
that contains the other lines <Compile Include=Foo.fs>
.