Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use nuget with fsharp on Linux

Tags:

linux

nuget

mono

f#

It's my first hours with F#, playing with it on Ubuntu Linux (14.04) but I am lost how to include install dependencies with nuget. I have nuget.exe working fine on Mono and i can nuget install packages; they land in my current directory. But then i can't import or open them from my example.fs file. I tried various options but to no avail. Do i need to write a project file or use FAKE? I couldn't find any tutorial which details the minimal necessary steps to setup a simple project.

So what do i need to do to access dependencies i installed with nuget?

like image 402
hpk42 Avatar asked Oct 12 '14 16:10

hpk42


1 Answers

The short answer is that it is not completely straightforward. The long answer is that you can approach the problem in a few different ways. All the methods I will suggest here use the MSBuild .fsproj projects, so that you can build with xbuild MyProject.fsproj. It's worth noting that FAKE scripts tend to use fsproj projects as well, and hand off to xbuild for the actual compilation. The fsharp.org website has some instructions on bootstrapping NuGet configuration and is a great resource in general.

  1. Use MonoDevelop. I recommend building from source. Get a tag from https://github.com/mono/monodevelop, and follow the instructions carefully. Then install the Nuget plugin. Create an F# project and use the interface in MonoDevelop to add NuGet packages to your project. You can then build from the command line or from MonoDevelop.

  2. Find an existing project that uses NuGet, gut it, and use the editor of your choice. A heavyweight example is https://github.com/fsprojects/ProjectScaffold, you can find others around there. Once you have this project downloaded you will be able to see how to edit the nuget.config file to adjust your dependencies.

  3. A recent project, Paket, offers a truly command-line approach to the problem at last. You again need an .fsproj skeleton (like this example), but you can then create a very simple dependencies file. Download the latest release of Paket from Github. Running mono paket.exe install will then use this file to fetch the dependencies from NuGet and add them to your .fsproj as references.

There is a bit of a bootstrapping problem, but any of these approaches should get you over the initial hump.

like image 111
rneatherway Avatar answered Oct 21 '22 19:10

rneatherway