简体   繁体   中英

How to reference the Dll in F# interactive in Visual Studio 2017 for a .Net core 2.1 application?

I created a .Net core 2.1 F# console application in Visual Studio 2017 on Windows. I would try the code in F# Interactive window. However, right-clicking the Dependencies will not show the command of sending the reference to F# Interactive window. Expanding the NuGet tree can find the DLL file names but they don't have the full path so I cannot manually run #r ".../full path/Akka.FSharp.dll";; .

  1. Where to find the DLL files?
  2. Is it possible to add the .Net core referenced DLL?

The code of the testing .Net core application.

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 

You cannot do this at this time as F# Interactive doesn't support .net core. 🙃 However as the API surface is almost identical to .net 4.7 and you can nuget necessary packages just reference it directly, just get whatever dlls are necessary directly and use #r :

#if INTERACTIVE
#r "System.IO.Compression.FileSystem.dll"
#endif

For example this will let you use some extension methods for zip archives by pulling in the compression dll from .net.

The .net core dlls will be packaged up in the publish folder, if you decide to create a framework independent pacakage. Whatever full framework dlls you would need for fsharp interactive just pull them down directly or to another project.

By the way, if you wonder where the .net core nuget packages get pulled down, it's in: C:\\Users\\$USERNAME\\.nuget\\packages . You should find net45 and netstandard2 versions when supported.

Update : In VS2019 preview F# Interactive is dotnetcore, and it's possible to reference dotnetstandard dlls.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM