Search code examples
xamarinf#monogame

Are there F# Monogame templates?


I want to experiment with Monogame in F# using Xamarin on OSX. I am able to create a working C# Monogame project and a working F# Cocoa app, but not a working F# Monogame project.

What is the boiler-plate setup for an F# Monogame project?

Are there Monogame F# templates available?


Solution

  • This is not a solution but a work-around: create two projects, one C# Monogame project and one F# console application. Both of these templates should be installed with Xamarin and Monogame.

    1. Create a C# Monogame project
    2. Create an F# console application
    3. Edit the fsproj file so that it has OutputType Library
    4. Link the F# project to the Monogame project
    5. Add the Monogame package to the F# library using nuget
    6. Write your Game class in F#!

    Aside from the hassle of creating two projects, the main problem I've found is that every reference used in the F# library also needs to be referenced in the C# library or you will get runtime errors. I'm sure a custom build script could be written to fix this.