How does F# Interactive #I command know about project path?

后端 未结 1 891
天涯浪人
天涯浪人 2021-02-08 10:22

Here is the scenario:

  1. Open Visual Studio. This was done in VS2010 Pro.
  2. Open F# Interactive within Visual Studio
  3. Open project with fsx file
1条回答
  •  感情败类
    2021-02-08 11:22

    In F# Interactive, the default directory to search is the source directory. You can query it easily using __SOURCE_DIRECTORY__.

    This behaviour is very convenient to allow you to use relative paths. You often have fsx files in the same folder with fs files.

    #load "Ast.fs"
    #load "Core.fs"
    

    When your refer to a relative path, F# Interactive will always use the implicit source directory as the starting point.

    #I ".."
    #r ... // Reference some dll in parent folder of source directory
    #I ".."
    #r ... // Reference some dll in that folder again
    

    If you want to remember the old directory for next reference, you should use #cd instead:

    #cd "bin"
    #r ... // Reference some dll in bin
    #cd "Debug"
    #r ... // Reference some dll in bin/Debug
    

    0 讨论(0)
提交回复
热议问题