开发者

F# scripting: Add new directory via #I

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜