ここにこのシナリオがあります。F#Interactive #Iコマンドはプロジェクトパスをどのように知っていますか?
- Visual Studioを開きます。これはVS2010 Proで行われました。 Visual Studioの内
- オープンF#インタラクティブFSXファイルと
- プロジェクトを開く
注:プロジェクトとFSXファイルはE:\<directories>\fsharp-tapl\arith
がFSXファイルからF#インタラクティブにコマンドを送信している
> System.Environment.CurrentDirectory;; val it : string = "C:\Users\Eric\AppData\Local\Temp"
私はいませんでした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#インタラクティブが現在arith.exeの場所を知らないことを示しています。
> #I @"bin\Debug" --> Added 'E:\<directories>\fsharp-tapl\arith\bin\Debug' to library include path
これで、Fith Interactiveにarith.exeの場所を伝えます。パスは絶対パスが、プロジェクトのサブパスではありません 注意してください。 私はF#インタラクティブにARITHプロジェクト
E:\<directories>\fsharp-tapl\arith
> #r @"arith.exe" --> Referenced 'E:\<directories>\fsharp-tapl\arith\bin\Debug\arith.exe'
の場所を告げておらず、F#インタラクティブが正しく正しい絶対パスを報告arith.exe見つけました。
> open Main > eval "true;" ;; true val it : unit =()
これはarith.exeが正しく検出され、読み込まれて動作することを確認しています。
現在のディレクトリは役に立たないので、F#Interactive #Iコマンドはどのようにプロジェクトパスを知っていましたか?私は本当にの後であるF#対話の中から1プロジェクト、E:\<directories>\fsharp-tapl\arith
へのパスを取得んどのようにしています何
。
EDIT F#インタラクティブで
> printfn __SOURCE_DIRECTORY__;;
E:\<directories>\fsharp-tapl\arith
val it : unit =()
をこれは本当にマティアスBrandewinderは、いくつかの[大きなヒントを持って興味を持っている人のために有用感謝...です](http:// brandewinder。com/2016/02/06/10-fsharp-scripting-tips /)を参照してください。ライブラリ内のスクリプトファイルからnugetパッケージにアクセスする際に問題が発生しました。#I @ ".. \ packages"が解決しました –