I am trying to use DotCover in FAKE , but it is throwing some error , as I am new to FAKE as well as F# , it's becoming difficult for me to understand the root cause of the problem . Here is the code :
#r "D:/FAKEProject/Fake/packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.DotCover
let testDir = "D:/FAKEProject/Fake/test/"
let filters = ""
Target "Clean" (fun _ ->
CleanDirs [testDir]
)
Target "TestCoverage" (fun _ ->
!! ("D:/FAKEProject/Fake/UnitTest/UnitTest.dll")
|> DotCoverNUnit
(fun p -> { p with Output = testDir @@ "NUnitDotCover.snapshot"
ToolPath = "D:/tools/dotCover/dotCover.exe"
Filters = filters })
(fun nunitOptions -> nunitOptions)
)
"Clean"
==> "TestCoverage"
RunTargetOrDefault "TestCoverage"`
It is giving this error
System.Exception: Error running D:/tools/dotCover/dotCover.exe with exitcode -1
at Fake.DotCover.buildParamsAndExecute@124-6.Invoke(String message) in C:\code\fake\src\app\FakeLib\DotCover.fs:line 124
at Fake.DotCover.buildParamsAndExecute[a](a parameters, FSharpFunc`2 buildArguments, String toolPath, String workingDir, Boolean failBuild) in C:\code\fake\src\app\FakeLib\DotCover.fs:line 124
at Fake.DotCover.DotCoverNUnit(FSharpFunc`2 setDotCoverParams, FSharpFunc`2 setNUnitParams, IEnumerable`1 assemblies) in C:\code\fake\src\app\FakeLib\DotCover.fs:line 190
at FSI_0005.DotCover.clo@16-2.Invoke(Unit _arg2) in D:\FAKEProject\Fake\DotCover.fsx:line 17
at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in C:\code\fake\src\app\FakeLib\TargetHelper.fs:line 492`
I am not able to understand why it is searching in C:\code\fake\src\app\fakelib\dotcover.fs and what is dotcover.fs it is looking for How to solve this problem , as I am stuck at this error , If anyone can help me regarding this , it would be very helpful .
Thank You
The mysterious
C:\code\fake\src\app\FakeLib\DotCover.fs
line is simply telling you the filename (and line number) of the source file that threw the error. Not the filename on your system, but the filename on the system where yourFAKE.exe
file was built. In other words, it's just telling you where the exception was thrown from.Looking at the FAKE source code, I see that line 124 is near the end of the following block of code:
The
failwithf
function is F#'s equivalent of "throw new Exception()", but it lets you specify a message (usingprintfn
-style format codes like%s
) to go with the exception. So there's nothing mysterious going on here in F#, it's just that yourD:/tools/dotCover/dotCover.exe
program has returned a -1 return code. Return codes of -1 usually mean "generic error", so that's not much help in figuring out the cause.Your next troubleshooting step is to run your
dotCover.exe
program manually, giving it the same arguments that FAKE is giving it (shouldn't be too hard to figure out, since the FAKE option records are usually pretty well-named) and the same input. Then see what error messages, if any,dotCover.exe
is printing out before it fails.