The other day I was working with a collegue on some quick file manipulation with F# interactive (.fsx) in VSCode using the excellent Ionide extension.
We ran into some trouble with Danish letters and encoding and I knew from previously that for reason Visual Studio seems to handle encoding problems in files somewhat better than VSCode. So we decided to try VS instead.
Don't worry, this post is not about encoding 😉
The Problem
However, we did not get very far with VS. We used the new F# 5.0 way of referencing Nuget packages:
#r "nuget: FSharp.Data"
But VS wouldn't let us have our way and it complained:
error FS3216: Package manager key 'nuget' was not registered in
...
[C:\program files (x86)\microsoft visual studio\2019\professional\common7\ide\commonextensions\microsoft\fsharp\Tools]
Intensive searching on the internet provided us with almost no help whatsoever, except for a bit help on Paket's page on fsi integration. Apparently we were the only two people in the world who could not get this stuff working.
The Solution
A bit more searching also revealed that FSharp.DependencyManager.Nuget is required. It is the F# extension manager for Nuget which gives us the coolness of #r "nuget"
.
That brings us to the final solution:
- Install FSharp.DependencyManager.Nuget with nuget.exe.
- Copy the file FSharp.DependencyManager.Nuget.dll to the directory mentioned in the error (in our case C:\program files (x86)\microsoft visual studio\2019\professional\common7\ide\commonextensions\microsoft\fsharp\Tools).
That's it. It took us only 2-3 hours to figure that out 🤦♂️🤦♂️.
I hope this can be helpful to the third person in the world that runs into this problem.
Top comments (5)
I suspect this is related to a recent change in Visual Studio that moved the F# interactive executable (
fsi.exe
) from...\Microsoft\FSharp
to...\Microsoft\FSharp\Tools
. See this SO question for details.I just checked my VS 16.10 installation and found
FSharp.DependencyManager.Nuget.dll
in...\Microsoft\FSharp
, even thoughfsi.exe
is now in...\Microsoft\FSharp\Tools
Thanks Jakob, signed up to dev.to just to express my gratitude for this and your impeachment fish.
I copied the existing
FSharp.DependencyManager.Nuget.dll
intoTools
wherefsi.exe
resides and got no stack overflow...I like F# too.
Recently I too have been faced with what should be simple problems that take hours. There's just too much complexity and "magic" everywhere.
Also, nice to see people using F#, it's a great language!
Yes, F# is indeed a great language!
Thanks for posting this. I have spent a lot of time trying to fix this issue on my own system.
It starts with
So I downloaded nuget.org/packages/FSharp.Dependen... and extract with 7zip
FSharp.DependencyManager.Nuget.dll
and place it intoC: \ Program Files (x86) \ Microsoft Visual Studio \ 2019 \ Community \ Common7 \ IDE \ CommonExtensions \ Microsoft \ FSharp \ Tools
. (I have tried this with a couple of the older dll versions too).When using F# interactive this generates a new warning:
and error:
so I used Brian Berns information and instead copied the dll across from
...\Microsoft\FSharp
to...\Microsoft\FSharp\Tools
replacing the version I had downloaded in the description above (and restarting visual studio). Now an F# interactive run generates the error:And now I am utterly stumped. Strangely, the same nuget dependency manager dll is working absolutely fine in VSCode.
Any ideas?