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.