6
votes

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.

2
Is your "Froto.Roslyn" DLL available in its own Nuget package? If not, how are you assuming that a client who downs "Froto.Gen.ProtoTypeProvider" has access to the dependency? If it isn't available, it won't work (which is why copying all of your dependencies into the Nuget package does work).Chris

2 Answers

4
votes

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).

3
votes

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