Joh has a nice blog describing the basics of compiling F# code for the XBox 360, including the magic command line to use to reference both the right copy of the F# core library and the right XNA DLLs. This is using the F# October 2009 CTP
This article describes how to build an XNA Game Studio application using an F# library in such a way that it can be run on the Xbox 360... A method was first described in this blog by Jack Palevich. Most of his blog post still applies, except for step 2.
In order for an .net assembly to be usable on the Xbox 360, it must be linked against dlls for the Xbox 360, which can be found in <Program Files directory>\Microsoft XNA\XNA Game Studio\v3.1\References\Xbox360. In particular, it must be linked against mscorlib.dll for the Xbox 360, which is the difficult part.
By default, when you create an F# library in Visual Studio, it is linked against FSharp.Core.dll, which references mscorlib for the PC. In order to avoid conflicts between versions of mscorlib, one must build an F# library targeted at the Compact Framework 2.0, which is what the XNA .net framework is built upon.
The ... solution is to compile the F# library using the F# compiler directly:
--standalone --noframework --define:TRACE --optimize+ --tailcalls+
-r:"C:\Program Files\Microsoft XNA\XNA Game Studio\v3.1\References\Xbox360\Microsoft.Xna.Framework.dll"
-r:"C:\Program Files\Microsoft XNA\XNA Game Studio\v3.1\References\Xbox360\mscorlib.dll"
-r:"C:\Program Files\Microsoft XNA\XNA Game Studio\v3.1\References\Xbox360\System.Core.dll"
-r:"C:\Program Files\Microsoft XNA\XNA Game Studio\v3.1\References\Xbox360\System.dll"
--target:library --warn:3 --warnaserror:76 --fullpaths --flaterrors
<your F# source files here>
Beside specifying the correct XNA assemblies using "-r:", this command line also does the following:
- Enables optimization using --optimize+ and --tailcalls+
- Embeds the F# core library in the assembly, using --standalone