Type providers with Nuget dependencies

42 views
Skip to first unread message

Adam Granicz

unread,
Apr 9, 2015, 3:55:34 PM4/9/15
to fsharp-o...@googlegroups.com
Hi guys,

Is there an example of a type provider that is packaged into a Nuget that in turn has other Nuget dependencies?  The type provider we are experimenting with follows this structure, but fails to load when invoked as it's unable to load its references (that are supposed to be coming from the referenced Nuget packages).

Thanks,
Adam.

--
Adam Granicz, IntelliFactory
www.intellifactory.com

Isaac Abraham

unread,
Apr 9, 2015, 4:09:49 PM4/9/15
to fsharp-o...@googlegroups.com
The azure storage type provider used that approach initially. It didn't work well, and I moved to bundling the dependencies directly in the package.

It's not a great solution but at least it worked.

From: Adam Granicz
Sent: ‎09/‎04/‎2015 20:55
To: fsharp-o...@googlegroups.com
Subject: Type providers with Nuget dependencies

--
--
To post, send email to fsharp-o...@googlegroups.com
To unsubscribe, send email to
fsharp-opensou...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensou...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tomas Petricek (Info)

unread,
Apr 9, 2015, 4:15:30 PM4/9/15
to fsharp-o...@googlegroups.com

Hi,

The R provider faces exactly this issue (it depends on R.NET). The way we solve it is that we register handler for the AssemblyResolve event handler (before anything causes loading of R.NET types) and look for the reference (using the expected NuGet/Paket folder structure).

 

The relevant place in the code is here:

https://github.com/BlueMountainCapital/FSharpRProvider/blob/e6777971afcb07205f84f600af9755c399c8f27c/src/RProvider.DesignTime/RProvider.fs#L27

There is also more documentation on how this works here:

http://bluemountaincapital.github.io/FSharpRProvider/devnotes.html

 

Note that to make this work, the library that sets up the AssemblyResolve handler must not contain any types that would require loading anything from the dependency (in our case, nothing from R.NET). AFAIK, this just means you shouldn’t have a public type inheriting from anything from R.NET (but I may be wrong here – we basically have all complex runtime in a separate assembly, partly for this reason).

 

Hope this helps! (And yes, it is a bit messy.. we also experimented with adding PowerShell script to copy the DLLs when NuGet packages are installed, but this does not work – restore packages in Visual Studio does not run the PowerShell script and it was fairly unpredictable anyway).

 

Tomas

 

From: fsharp-o...@googlegroups.com [mailto:fsharp-o...@googlegroups.com] On Behalf Of Adam Granicz
Sent: Thursday, April 9, 2015 9:56 PM
To: fsharp-o...@googlegroups.com
Subject: Type providers with Nuget dependencies

 

Hi guys,

--

Isaac Abraham

unread,
Apr 9, 2015, 4:28:46 PM4/9/15
to fsharp-o...@googlegroups.com
I should point out I tried the PowerShell approach at first as well, as Tomas says its not reliable. Paket also won't ever support PowerShell scripts.

From: Tomas Petricek (Info)
Sent: ‎09/‎04/‎2015 21:15
To: fsharp-o...@googlegroups.com
Subject: RE: Type providers with Nuget dependencies

Adam Granicz

unread,
Apr 10, 2015, 4:45:55 PM4/10/15
to fsharp-o...@googlegroups.com
This helped us resolve the issue, thanks!
Reply all
Reply to author
Forward
0 new messages