Chances are you trying to BenchmarkDotNet to test your Fsharp/F# code. The easiest way to run F# code with BenchmarkDotNet is to build your project in Release mode.

If you really want to debug to the benchmark this is not the right article. This article is about building your FSharp project for Release.

We explore two ways to do this in this article:

1. Using Rider IDE

By default Rider will build the project in Debug mode. So you will need to go to Build->Change Solution Configuration… Then you will need to choose “Release | Any CPU”. Now you can build and run your code and it should work.

2. Using terminal / command line

You will need to add an additional parameter to your dotnet build as follows:

 dotnet build -c Release

The dash c Release tells dotnet to build it for Release. Alternatively you can also use dotnet run as follows:

dotnet run --project YourFSharpProject -c Release

This should be enough to get you going. There are plenty of other articles about how to write BenchmarkDotNet in FSharp so we will not cover it here. Have fun!