Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I distribute an F# Type Provider via NuGet?

My F# type provider doesn't seem to be working unless all its dependencies are in the same folder. This doesn't work very well for distributing type providers via nuget. Any suggestions on how to resolve this?

I'll get errors like: error FS3033: The type provider 'Froto.Gen.ProtoTypeProvider' reported an error: Could not load file or assembly 'Froto.Roslyn, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

The type provider is in this library: packages\Froto.Gen.0.0.0.1\lib\net45\Froto.Gen.dll

The dependencies are all in the project. If I copy all of them into packages\Froto.Gen.0.0.0.1\lib\net45\, the type provider works.

2012-11-19 Update: I'll create a NuGet package today to explain the problem better.

like image 200
Cameron Taggart Avatar asked Nov 18 '12 20:11

Cameron Taggart


2 Answers

This issue is not F# specific. You absolutely have to either

  • ship all required dependencies as part of your nuget package
  • let NuGet know that your package depends on other packages that will provide the required references

A nuget package can easily contain multiple dlls (if packaged correctly). You can read more abou how to create a package here: http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package

Should you have trouble integrating NuGet with your projects msbuild scripts, I recommend taking a look at the scripts other open source projects use to build their NuGet packages (e.g. check out FSharpX or FSharp Power Pack).

like image 55
Johannes Rudolph Avatar answered Sep 16 '22 12:09

Johannes Rudolph


There was a similar problem with FSharpx.TypeProviders that dependend on FSharpx.Core. The solution was to use ILMerge to merge all the dependencies into the type provider. Check the thread in https://github.com/fsharp/fsharpx/issues/91

like image 32
Gustavo Guerra Avatar answered Sep 16 '22 12:09

Gustavo Guerra