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

?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top