How to compile without IDE or project files ? Can F# be used inline in aspx files under IIS?

Hi all,

I was checking IronPython in order to evaluate if I can replace C# in some projects then I stumble upon F# on my way.

Got two small newbie questions ( complexity level == “Hello world” :slight_smile: )

I’ve got a simple F# file here:

let main argv =
    printfn "Hi there"

But I can’t find a simple way to compile it without using IDE’s or fsproj files (which I don’t want to).
I’ve googled about this but I can only find answers using IDE’s or project files.
Anyone could explain how to compile a simple F# file down to an exe and how to compile to a dll (if possible with F#)

Also, I’d like to know if it’s possible to use F# inline in an aspx file ?
Here’s a simple C# aspx file, how can I replace the C# language to F# ? Do I need extra web handlers to install ?

<%@ Page language="C#" Debug="true" validateRequest="false" responseEncoding="utf-8"%>

HttpContext.Current.Response.Write("Hi there");

If it’s not possible to use F# inline in aspx files, can I compile it down to a dll and call some code from the C# aspx page ?

Thanks in advance for you answers !

I can answer the first question.
To compile F# you can invoke the F# Compiler: FSC.EXE which you can find in the nuget package FSharp.Compiler.Tools or installed somewhere in your computer by VSCode or Visual Studio.

In the parameters you indicate the input files and output targets as well as referenced libraries.

Here is an example to compile a dll (notice --target:library):

-r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll"  
-I:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1"  
-I:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades"  

I’m showing the options as separate lines for clarity but all the parameters go in the same line.

Here is the Compiler documentation: Compiler Options - F# | Microsoft Docs

Yes, it is possible. See a very old example at An Introduction to the F# Programming Language (

Also, more information about F# web development at Guide - Web Programming | The F# Software Foundation (

Answering your very last question, if you compile some F# into a DLL it’s just like a C# class library and you can absolutely use it from C#, they are both .net assemblies. To make it really easy you can create classes with methods in the F# code (which might just wrap around fully functional style code) and then use it just as if it were a C# library.

This can be a very good way to start adding some F# code into an existing .net project that was written in C# (and / or VB) especially if you need to implement some algorithms or business logic where correctness or better domain modelling (for example) is important.

@amieres Thanks ! I realize that I don’t have the fsc binary although I have an fsc.dll in /usr/share/dotnet/sdk/5.0.301/FSharp (forgot to mention I was doing my tests on linux)

@Scott Thanks for the links !

@realparadyne good catch ! Indeed I could start migrating iteratively using the method you propose.