FSharp.Core implicit reference versus explicit PackageReference after .NET SDK upgrade
0 reputation · 01 Feb 2026, 17:13 UTC
0 reputation · 01 Feb 2026, 17:13 UTC
An F# project using Microsoft.NET.Sdk builds with the .NET 6 SDK and relies on the SDK-implicit FSharp.Core reference. The goal is to move the project to a later .NET SDK without changing the compiler or standard-library combination from the last known-good build.
.NET 6 expects F# 6 and may resolve FSharp.Core 6.x unless the project file pins the package or LangVersion. The exact precedence between an explicit FSharp.Core PackageReference and the SDK-implicit reference across SDK releases is not documented as a stable compatibility guarantee. Side-by-side SDK selection through global.json, environment variables, PATH, and RollForward can also cause an older project to compile with a newer compiler after an upgrade.
Because the F# compiler and .NET SDK do not provide an upgrade rollback or pre-upgrade snapshot, the wrong resolution could change behavior silently, and recovery would depend on backups or version control rather than an F# command.
Does an explicit FSharp.Core PackageReference override the SDK-implicit FSharp.Core reference in .NET 7 SDK and later? Should LangVersion be pinned when FSharp.Core is pinned across SDK upgrades? Which SDK selection source takes precedence when global.json is absent and multiple SDKs are installed?
37775 reputation · 01 Feb 2026, 22:21 UTC
Yes—for an SDK-style F# project, an explicit PackageReference to FSharp.Core normally overrides the SDK-implicit FSharp.Core reference. This is MSBuild/SDK target behavior, not a documented stable compatibility guarantee across .NET 7 and later SDKs. Pin LangVersion separately if you must keep the same F# language version, because pinning the package does not pin the compiler binary. When global.json is absent, DOTNET_ROOT takes precedence if set; otherwise the first dotnet on PATH chooses the SDK root, and the latest SDK in that root subject to roll-forward is used.
SDK targets are imported after the project file and can add or change the implicit FSharp.Core reference. If the project file also contains an explicit PackageReference, MSBuild usually applies the explicit item, but duplicate FSharp.Core entries with different versions can produce restore or build warnings and leave the effective version dependent on import order and SDK properties. A later SDK can still compile with a newer F# compiler against an older pinned library.
FSharp.Core PackageReference is the standard way to pin the library version.FSharp.Core does not pin Fsc, the SDK, or LangVersion.FSharp.Core 6.x; .NET 7 and later SDKs default to later versions. Treat this as version-specific behavior to verify after an upgrade.global.json: DOTNET_ROOT, then first dotnet on PATH, then latest installed SDK subject to DOTNET_ROLL_FORWARD.None of these behaviors should be treated as a rollback mechanism. Re-verify reference resolution after every SDK upgrade.
PackageReference to FSharp.Core at the last known-good version.LangVersion to the same property group if the language version must remain unchanged.FSharp.Core PackageReference entries.global.json, DOTNET_ROOT, or PATH if the compiler binary must stay the same.dotnet --list-sdks
dotnet --info
where dotnet # Windows
which dotnet # macOS/Linux
dotnet build -v:d | findstr FSharp.Core # Windows
dotnet build -v:d | grep FSharp.Core # macOS/Linux
dotnet msbuild -pp:preprocessed.xml
dotnet build -bl
Search verbose build output for FSharp.Core to confirm one explicit entry at the pinned version. Inspect the preprocessed project or binary log for duplicate entries and SDK import order. Check the Fsc path and version; LangVersion restricts language features but does not change the compiler.
Confirm which SDK root the build actually uses before deciding whether global.json is required. Run dotnet --info and compare DOTNET_ROOT, the resolved dotnet path, and the installed SDK list. If the build already resolves the older SDK, package and language pins may be enough; if it resolves the newer SDK, pin the SDK root as well.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.