Question

How could I make this work?

#I (__SOURCE_DIRECTORY__ + @"\bin\Release")

And second questions. Is it possible to do something like:

let path = __SOURCE_DIRECTORY__ + @"\bin\Release"
#I path

?

Was it helpful?

Solution

You can't. The #I and #r commands are really pre-processor instructions that are executed before the code is dynamically compiled by fsi, so they only support string literals. This is logical if you think about it, as the referenced assemblies maybe need to compile the code.

However, the #r and #I command always take relative paths as being from the scripts location, so this

#I @".\bin\Release"

should work just fine (note the dot to ensure it’s a relative not an absolute path).

Note that runtimes relative paths are from the fsi working directory (normally the temp directory) so you do need to use __SOURCE_DIRECTORY__ when loading files from you’re scripts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top