Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 
like image 675
ca9163d9 Avatar asked Sep 16 '18 19:09

ca9163d9


People also ask

How do I add a reference to a DLL in TFS?

To add files to tfs: from command line, go to the directory containing assemblies and type "tf add foo. dll" OR in Source Control Explorer, go to the location where the assemblies should be and click "Add to Source Control" on the toolbar or from File->Source Control.

Can a DLL reference another DLL?

Any DLL that lays somewhere in file system can be referenced. After compilation this DLL must be either in GAC (Global Assembly Cache) or in same directory with the working application.


1 Answers

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.

like image 175
s952163 Avatar answered Oct 11 '22 10:10

s952163