- Get .NET SDK with
sudo apt install dotnet9
(ordotnet-sdk-9.0
),brew install dotnet
for macOS - Get FSharpPacker tool with
dotnet tool install -g --allow-roll-forward FSharpPacker
- Make an F# interactive script file (e.g. copy the
phash.fsx
below) - Compile it with
fspack {your-script.fsx} -f net9.0 -o {destination} --aot
(in this example:fspack phash.fsx -f net9.0 -o . --aot
), note that it will take some time to do so for the first time - .NET needs to fetch IL AOT Compiler from Nuget - Profit! You have compiled an F# script to a native binary
- (Optional) If you add fspk.fish, the process is simplified to
fspk {my-script}.fsx
!
Note 1: if you are not using macOS or FreeBSD, give https://github.com/ieviev/fflat a try which can produce even smaller binaries