Since some folks from ##fsharp on irc.freenode.net requsted it, I’m going to put up the stuff I actually remember about getting F# projects on Linux/Mono to compile under XBuild. This guide assumes that you have successfully built and installed the F# tooling from source.
Most of the stuff that needs to be done is hacking. A sane setup shouldn’t need the amount of hackery I’ve done to get this to work.
Also, I’d like to thank shana and mhutch @ irc.gnome.org for their help with getting this done. As far as I know, shana is also working on getting some better Debian packaging put together (so that the package on CodePlex isn’t totally broken).
The first hack we’re going to do is creating the directory where XBuild expects to find Microsoft.FSharp.targets. If your Mono installation is prefixed to /usr/local, this will be /usr/local/lib/mono/Microsoft F#/v4.0. So go ahead and create that.
Now we’re going to throw in the actual MSBuild file. We just grab it off the source repository, here:
https://github.com/fsharp/fsharp/raw/master/lib/bootstrap/4.0/Microsoft.FSharp.targets
With this file in place (in /usr/local/lib/mono/Microsoft F#/v4.0), XBuild will now have something usable for building F# projects.
You might get an error regarding _ComputeNonExistentFileProperty when trying to build a project. If so, simply locate it in /usr/local/lib/mono/4.0/Microsoft.Common.targets, and uncomment it. It does no harm.
Now, back to hacking: We need to create a series of symbolic links to the F# runtime libraries in /usr/local/lib/mono/Microsoft F#/v4.0. Ideally, this should be fixed in Microsoft.FSharp.targets at some point, but my knowledge about MSBuild is quite limited, so I haven’t dared to do an attempt.
Anyhow, in the aforementioned directory, ensure that you have a layout like so:
FSharp.Build.dll –> /usr/local/lib/mono/4.0/FSharp.Build.dll FSharp.Core.dll –> /usr/local/lib/mono/4.0/FSharp.Core.dll FSharp.Core.dll.optdata –> /usr/local/lib/mono/4.0/FSharp.Core.dll.optdata FSharp.Core.dll.sigdata –> /usr/local/lib/mono/4.0/FSharp.Core.dll.sigdata
This should make XBuild happy. However, I haven’t actually tested this; I’m just recalling from memory – so, feedback is welcome!
Edit: Tim Robinson mentions that the instructions are the same on OS X, except that Mono will be installed in /Library/Frameworks/Mono.framework/Versions/Current instead of /usr/local.
The instructions for Mac OS X are the same, except that Mono will be installed at /Library/Frameworks/Mono.framework/Versions/Current instead of /usr/local.
I just committed fixes for this in master branch of Mono (and committed fixes for fsharp master branch some weeks ago).
So we should not need any hackery anymore after Mono 2.11.5 is released.