diff --git a/FSharp.Profiles.props b/FSharp.Profiles.props
index 4627fcace39..811ee0d0e40 100644
--- a/FSharp.Profiles.props
+++ b/FSharp.Profiles.props
@@ -23,7 +23,7 @@
- $(OtherFlags) /checknulls
+ enable
diff --git a/src/FSharp.Build/Fsc.fs b/src/FSharp.Build/Fsc.fs
index 9de88c9dbca..24952eceea1 100644
--- a/src/FSharp.Build/Fsc.fs
+++ b/src/FSharp.Build/Fsc.fs
@@ -95,6 +95,7 @@ type public Fsc() as this =
let mutable vslcid: string MaybeNull = null
let mutable utf8output: bool = false
let mutable useReflectionFreeCodeGen: bool = false
+ let mutable nullable: bool option = None
/// Trim whitespace ... spaces, tabs, newlines,returns, Double quotes and single quotes
let wsCharsToTrim = [| ' '; '\t'; '\"'; '\'' |]
@@ -205,6 +206,13 @@ type public Fsc() as this =
if not tailcalls then
builder.AppendSwitch("--tailcalls-")
+ match nullable with
+ | Some true ->
+ builder.AppendSwitch("--checknulls+")
+ builder.AppendSwitch("--define:NULLABLE")
+ | Some false -> builder.AppendSwitch("--checknulls-")
+ | None -> ()
+
// PdbFile
builder.AppendSwitchIfNotNull("--pdb:", pdbFile)
// Platform
@@ -649,6 +657,18 @@ type public Fsc() as this =
with get () = subsystemVersion
and set (p) = subsystemVersion <- p
+ member _.Nullable
+ with get () =
+ match nullable with
+ | None -> ""
+ | Some true -> "enable"
+ | Some false -> "disable"
+ and set (p) =
+ match p with
+ | "enable" -> nullable <- Some true
+ | "disable" -> nullable <- Some false
+ | _ -> ()
+
member _.HighEntropyVA
with get () = highEntropyVA
and set (p) = highEntropyVA <- p
diff --git a/src/FSharp.Build/Microsoft.FSharp.Targets b/src/FSharp.Build/Microsoft.FSharp.Targets
index 0ac058e30ba..7334f979086 100644
--- a/src/FSharp.Build/Microsoft.FSharp.Targets
+++ b/src/FSharp.Build/Microsoft.FSharp.Targets
@@ -412,7 +412,8 @@ this file.
WarnOn="$(WarnOn)"
Win32IconFile="$(ApplicationIcon)"
Win32ManifestFile="$(Win32Manifest)"
- Win32ResourceFile="$(Win32Resource)">
+ Win32ResourceFile="$(Win32Resource)"
+ Nullable="$(Nullable)">