This is something I discovered ages ago and should have been in my original Gotchas: Common Traps for the F# n00b post. I figured out how to add assembly level attributes to one of my F# assemblies but forgot to include it in the post.
The gotcha is that because F# projects don’t include a default AssemblyInfo.fs file you’re left to figure this out for yourself. If you do the obvious thing and just add the attribute (example in lines 9-13 below) you’ll see the following error:
This attribute is not valid for use on this language element. Assembly attributes should be attached to a ‘do ()’ declaration, if necessary within an F# module.
It turns out that the module needs an empty do() statement at the end of it. So your assemblyInfo.fs file might look something like this.
Note the do() at line 15. Adding this fixes the problem and the code compiles.