Search This Blog

Sunday, March 27, 2011

Ordering files in MonoDevelop's F# Plug-in

I have been using Tomas Petricek's F# Plug-in for MonoDevelop a lot recently for some personal projects. The addition of code-completion and on-the-fly compilation has been a nice upgrade from XCode. Mostly it was working well until I added a new module and the main program file couldn't find it and just reported errors. It built fine using my Makefiles.

After looking at the compiler output I realized that the ordering of the files was wrong. The F# compiler enforces strict, non-cyclic dependencies between files (modules) and requires the order of the files on the command line reflect this. That is, the modules with no dependencies (except references) come first, and those dependent on the earlier ones come next.

For example, assume we are building a .DLL with files A.fs, B.fs, and C.fs. If files B and C are independent, but file A references both B and C then A must come after both B and C on the compile line:
    mono fsc.exe [references] B.fs C.fs A.fs

I knew what the issue was but haven't been able to find a way in MonoDevelop to control this. Finally while watching the Australian Grand Prix this morning I found it. Experienced MonoDevelop users probably already know this, though it isn't necessary for C#, but I finally found the option to control the build order.

Under the Project Options menu item (either Project Menu or the right-click popup menu), find the heading 'Build' and click on the 'General' item. This brings up two tabs in the right-hand display both oddly named 'General' as well. The second one controls the build order. Once I fixed the build order to reflect the file dependencies I closed and re-openened the editor tabs and all is well again!

1 comment:

  1. I had this problem too, but now I can't fix it, because any and every time I click on the "General" option (under Build), MonoDevelop just crashes, so I'm screwed.

    ReplyDelete