如何为.Net core 2.1应用程序在Visual Studio 2017中引用F#交互式Dll?

ca9*_*3d9 5 f# visual-studio .net-core visual-studio-2017

我在Windows上的Visual Studio 2017中创建了.Net core 2.1 F#控制台应用程序。我会在F#Interactive窗口中尝试该代码。但是,右键单击Dependencies不会显示将引用发送到F#Interactive窗口的命令。展开NuGet树可以找到DLL文件名,但是它们没有完整的路径,因此我无法手动运行#r ".../full path/Akka.FSharp.dll";;

  1. 在哪里可以找到DLL文件?
  2. 是否可以添加.Net核心引用的DLL?

测试.Net核心应用程序的代码。

open System
open Akka.FSharp

let system = System.create "MovieStreamingActorSystem" <| Configuration.load ()

type ProcessorMessage = ProcessJob of int * int * string

let processor (mailbox: Actor<ProcessorMessage>) =
    let rec loop () = actor {
        let! m = mailbox.Receive ()
        printfn "Message %A" m
        return! loop ()
    }
    loop ()

[<EntryPoint>]
let main argv =
    let processorRef = spawn system "processor" processor
    processorRef <! ProcessJob(1, 2, "3")
    0 
Run Code Online (Sandbox Code Playgroud)

s95*_*163 4

目前您无法执行此操作,因为 F# Interactive 不支持 .net core。然而,由于 API 表面几乎与 .net 4.7 相同,您可以直接引用它来获取必要的包,只需直接获取所需的 dll 并使用#r

#if INTERACTIVE
#r "System.IO.Compression.FileSystem.dll"
#endif
Run Code Online (Sandbox Code Playgroud)

例如,这将允许您通过从 .net 中提取压缩 dll,对 zip 存档使用一些扩展方法。

publish如果您决定创建一个独立于框架的包,.net core dll 将打包在该文件夹中。无论 fsharp Interactive 需要什么完整的框架 dll,只需将它们直接拉下来或拉到另一个项目即可。

顺便说一句,如果您想知道 .net core nuget 包在哪里被下载,它位于: C:\Users\$USERNAME\.nuget\packages。您应该找到支持的 net45 和 netstandard2 版本。

更新:在 VS2019 预览版中,F# Interactive 是 dotnetcore,并且可以引用 dotnetstandard dll。