0

I'm trying to compile an F# program that wants to use arbitrary precision rational numbers. The source code contains

open MathNet.Numerics

and MathNet.Numerics and MathNet.Numerics.FSharp are installed in such a way that Visual Studio is happy. Now I'm trying to compile the program from the command line using fsc directly (in order to have more control over what's going on). Clearly, the compiler needs to be told about the referenced assembly.

I've tried

fsc -r:MathNet.Numerics ...

but it says

error FS0082: Could not resolve this reference. Could not locate the assembly "MathNet.Numerics". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. (Code=MSB3245)

Presumably I need to use some other option that tells fsc where to look for the assembly in question. Which option should I use, and what location should I supply? (There are quite a few copies of various versions of MathNet.Numerics.dll on the machine; it's not clear which should be regarded as canonical for this purpose.)

rwallace
  • 31,405
  • 40
  • 123
  • 242
  • Why not use a NuGet package reference? Both Ionide (for VSCode) and VS itself have support to add NuGet package reference to the build. The build systems then handle where the package is cached locally. – Richard Feb 12 '22 at 15:16
  • Why do you need this power? How are you going to use it? The purpose of build systems is to make life easier by collecting necessary references, handling flags for compiler, cleaning before build and so on. If you want to dig into, use MSBuild binary logging to gather info on how build is done step-by-step. In my case building console application required passing **206** arguments to compiler – JL0PD Feb 12 '22 at 15:38

1 Answers1

2

You can specify the full path to the assembly with -r, not just the file name. For me, it looks like this:

-r:C:\Users\MyName\.nuget\packages\mathnet.numerics\4.15.0\lib\netstandard2.0\MathNet.Numerics.dll

Alternatively, you can use -I:folder-name to specify a directory to be searched for assemblies that are referenced.

These compiler options are documented here.

Brian Berns
  • 15,499
  • 2
  • 30
  • 40