fflat 2.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global fflat --version 2.0.5
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local fflat --version 2.0.5
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=fflat&version=2.0.5
                    
nuke :add-package fflat --version 2.0.5
                    

fflat - F# native script compiler on bflat

<img alt="Nuget" src="https://img.shields.io/nuget/v/fflat">

Build 1MB native executables from .fsx scripts!

alternate text is missing from this package README image

Installation

dotnet tool install --global fflat

Basic usage

fflat script.fsx             # about 1.4M, no debug/globalization/symbols
fflat script.fsx --small     # about 1MB, no reflection/exceptions, no printfn!

run fflat --help for a list of options

Advanced usage

arm64 executable

fflat script.fsx --small build --arch arm64 # 1.2MB and runs on raspberry pi! 👍

using fflat to as an interface to the F# compiler

fflat ./mylibrary.fsx build-il --watch ## quickly recompiles mylibrary.dll on every change 

bflat arguments are specified after build

fflat ./helloworld.fsx --small build -x -r "mylibrary.dll" --os windows ## ... etc

Shared library (experimental)

fflat script.fsx [--small] build-shared
all options
MAIN:

    <script>              .fsx script file path (first argument)

SUBCOMMANDS:

    build <options>       compile to native with bflat [default]
    build-il <options>    compile to IL (using fsc)
    build-shared <options>
                          compile to shared library

    Use 'fflat <subcommand> --help' for additional information.

OPTIONS:

    --verbose, -v         verbose output
    --version             version of application
    --ldflags <string>    <ldflags>
    --noreflection        disable reflection
    --arch <unknown|arm|arm64|x64|x86|wasm32|loongarch64>
                          <x64|arm64>
    --os <unknown|windows|linux|uefi>
                          <linux|windows|uefi>
    --optimize <none|prefersize|blended|preferspeed>
                          <preferspeed|prefersize>
    --tiny, -t            smallest possible executable. NB! avoid using printfn with this
    --small, -s           small executable but retains reflection, stack trace and exception
                          messages
    --output, -o <outputFile>
                          output executable path
    --help                display this list of options.

Common questions, troubleshooting

Why?

there is almost a 1000x difference in startup time for dotnet fsi scripts using nuget!

alternate text is missing from this package README image

there is also FSharpPacker for .fsx scripts, which compiles .fsx scripts to native executables using the standard MSBuild pipeline (PublishAOT), but bflat can produce significantly smaller executables or even omit the .NET runtime/GC all together.

TypeInitialization_Type_NoTypeAvailable errors

use --small instead of --tiny, --tiny will crash if your script uses any reflection features.

there's many untrimmable features in the F# core library like printfn, quotations and linq. substituting all printfn calls with stdout.WriteLine will produce significantly smaller binaries as well.


Have fun!

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
2.1.3 257 2/4/2026
2.1.2 164 2/4/2026
2.1.1 188 2/3/2026 2.1.1 is deprecated because it has critical bugs.
2.1.0 192 2/2/2026 2.1.0 is deprecated because it has critical bugs.
2.0.7 1,179 12/13/2024
2.0.5 691 12/13/2024
1.0.53 3,438 7/6/2024
1.0.52 3,201 7/6/2024
1.0.49 7,238 6/22/2024
1.0.48 8,546 1/30/2024
1.0.47 3,395 1/30/2024
1.0.46 11,575 11/18/2023
1.0.44 4,313 10/18/2023
1.0.43 2,654 10/9/2023
1.0.36 2,447 10/9/2023
1.0.34 1,823 10/8/2023
1.0.33 2,799 10/8/2023