-
Notifications
You must be signed in to change notification settings - Fork 314
Description
Hi
I am looking to upgrade our setup from Fable 4 + .NET 8 to Fable 5 + .NET 10, and in this process I got results that I could not easily explain.
But I have now pinned down the reason for some of the confusing results:
MSBuildCracker does NOT respect global.json (and hence does NOT use the SDK version specified for the repo)
This can result in a project failing to build with dotnet build but not with dotnet fable (or the other way around).
This is confusing when trying to investigate issues related to version upgrades 😊
This is a breaking change from the legacy cracker in Fable 4 which does respect global.json.
Steps to verify
- Install both .NET SDK 8 and .NET SDK 10 on the machine (verify with
dotnet --info). - Fix the SDK version to .NET 8 in
global.jsonin your repo, e.g.:{"sdk": {"version": "8.0.416","rollForward": "latestFeature"}} - Set the
TargetFrameworktonet42.0(or some other non-released version) in your project file. This is just to provoke an error in the restore process. - Run
dotnet build. Observe that the error is produced by SDK 8, e.g.:/usr/local/share/dotnet/sdk/8.0.416/Sdks/Microsoft.NET.Sdk/.... - Run
dotnet fable. Observe that the error is produced by SDK 10, e.g.:/usr/local/share/dotnet/sdk/10.0.100/Sdks/Microsoft.NET.Sdk/....
This affects both Fable 4.27.0 (using --test:MSBuildCracker) and Fable 5.0.0-alpha.14.
Where to look
It is likely caused by this line: https://github.com/fable-compiler/Fable/blob/main/src/Fable.Compiler/MSBuildCrackerResolver.fs#L35
psi.WorkingDirectory <- Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)But there is no comment in the surrounding code explaining why dotnet msbuild should run in user profile directory rather than in the directory in where dotnet fable was called from (and hence would pick up the correct global.json file).
Machine Info
- OS: macOS 26.1
- .NET SDK:
8.0.416and10.0.100 - Fable:
4.27.0and5.0.0-alpha.14