Visual studio F#Interactive#I command如何知道项目路径?

Visual studio F#Interactive#I command如何知道项目路径?,visual-studio,f#,f#-interactive,Visual Studio,F#,F# Interactive,以下是场景: 打开VisualStudio。这是在VS2010 Pro中完成的 在Visual Studio中打开F#交互式 使用fsx文件打开项目 注意:项目和fsx文件位于E:\\fsharp tapl\arith 从fsx文件向F#Interactive发送命令 > System.Environment.CurrentDirectory;; val it : string = "C:\Users\Eric\AppData\Local\Temp" 我不希望有临时目录,但这是有道理的

以下是场景:

  • 打开VisualStudio。这是在VS2010 Pro中完成的
  • 在Visual Studio中打开F#交互式
  • 使用fsx文件打开项目
    注意:项目和fsx文件位于
    E:\\fsharp tapl\arith
  • 从fsx文件向F#Interactive发送命令

    > System.Environment.CurrentDirectory;; 
    val it : string = "C:\Users\Eric\AppData\Local\Temp"
    
    我不希望有临时目录,但这是有道理的

    > #r @"arith.exe"
    Examples.fsx(7,1): error FS0082: Could not resolve this reference. 
    Could not locate the assembly "arith.exe". 
    Check to make sure the assembly exists on disk. 
    If this reference is required by your code, you may get compilation errors. 
    (Code=MSB3245)
    
    Examples.fsx(7,1): error FS0084: Assembly reference 'arith.exe' was not found 
    or is invalid
    
    #r命令错误显示F#Interactive当前不知道arith.exe的位置

    > #I @"bin\Debug"
    --> Added 'E:\<directories>\fsharp-tapl\arith\bin\Debug' 
    to library include path
    
    这确认arith.exe已正确找到、加载并正常工作

  • 既然当前目录没有帮助,那么F#Interactive#I命令是如何知道项目路径的呢

    我真正想要的是从F#Interactive中找到项目的路径,
    E:\\fsharp tapl\arith

    编辑

    >printfn\uuuu源目录;;
    E:\\fsharp tapl\arith
    val it:unit=()
    
    在F#Interactive中,要搜索的默认目录是源目录。您可以使用
    \uuuuu源目录\uuuuu
    轻松查询它

    这种行为非常方便,允许您使用相对路径。您通常会将
    fsx
    文件与
    fs
    文件放在同一文件夹中

    #load "Ast.fs"
    #load "Core.fs"
    
    当您引用相对路径时,F#Interactive将始终使用隐式源目录作为起点

    #I ".."
    #r ... // Reference some dll in parent folder of source directory
    #I ".."
    #r ... // Reference some dll in that folder again
    
    如果要记住旧目录以供下次参考,应使用
    #cd

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

    这真的很有用谢谢。。。对于任何有兴趣的人,Mathias Brandewinder都有一些关于fsx脚本的经验。我在试图从库中的脚本文件访问nuget软件包时遇到问题,#I@.\packages”解决了这个问题
    #load "Ast.fs"
    #load "Core.fs"
    
    #I ".."
    #r ... // Reference some dll in parent folder of source directory
    #I ".."
    #r ... // Reference some dll in that folder again
    
    #cd "bin"
    #r ... // Reference some dll in bin
    #cd "Debug"
    #r ... // Reference some dll in bin/Debug