6

I have an .fsproj (and .sln) from an F# project that was developed on Windows that I want to build on the Mac.

I've built several single-source-file F# programs with Mono, and it's great. Unfortunately, this .fsproj is non-trivial, as there are several source files and a number of references.

Devising the command line to build the project by hand doesn't seem fun.

Is there a tool that will analyze the .sln/.fsproj and give the correct command line? Or perhaps just do the build from the .sln/.fsproj?

I'd like to do this without MonoDevelop or SharpDevelop if possible, though answers along those lines are welcome.

Harold
  • 1,584
  • 1
  • 12
  • 20
  • See http://stackoverflow.com/questions/254722/how-can-i-build-a-visual-studio-solution-using-xbuild-from-mono as F# projects should be normal msbuild projects. – JPW Nov 21 '11 at 20:58
  • I just tend to use makefiles - once you have written a few it becomes very easy – John Palmer Nov 21 '11 at 21:56
  • @JohnPalmer do you have an example or template to share? – Harold Nov 22 '11 at 04:10

2 Answers2

3

Here is a simple makefile that I use

FSC=/home/john/FSharp-2.0.0.0/bin/fsc.exe
FSFILES= tokenizer.fs BuildTree.fs symtable.fs mkVMCommands.fs codegen.fs
compiler: compiler.exe

compiler.exe: $(FSFILES)
    $(FSC) --define:LINUX --debug:full --debug+ $(FSFILES) -o:compiler.exe --sig:sigfile.fs

run: compiler
    mono compiler.exe

note that the lines after each target - compiler.exe:... need to be indented with a TAB rather than spaces. If you need reerences, you just add -r "Somefile.dll" to the commandline.

John Palmer
  • 25,356
  • 3
  • 48
  • 67
  • Interesting. And decidedly more minimal than the .fsproj file. Thanks for sharing this. It seems like having a tool to produce this from the .fsproj would be useful, updating both by hand seems error prone. – Harold Nov 22 '11 at 04:55
  • @Harold - I don't know of any automatic tools to convert between .fsproj files and makefiles, but I have found that updating the makefiles by hand is pretty easy – John Palmer Nov 22 '11 at 05:07
2

You may want to look at xbuild, which directly read sln and fsproj files and build them on Mono platform.

As @JPW mentioned in the comment, it also works on Mac OS X. Although xbuild's F# support seems to be immature, someone has managed to build F# projects with xbuild on Linux. Hopefully, it is helpful for you to set up the build environment on Mac.

Community
  • 1
  • 1
pad
  • 41,040
  • 7
  • 92
  • 166