Search code examples
.netf#nugetfable-f#paket

F# - unwanted reference to FSharp.Core 9.0 after paket clear-cache causes build error


I recently ran a somewhat bold paket clear-cache and my F# application started behaving strangely. Some of my projects that were referencing an older version of FSharp.Core now reference the new v9.0.

I never paid attention to it, maybe a similar move was also bumping versions before but it has always transparent for me. Now I wouldn't mind if I didn't get this dreaded error at compile time this time: File '.../.nuget/packages/fsharp.core/9.0.100/lib/netstandard2.0/FSharp.Core.optdata' not found alongside FSharp.Core.

What I tried so far:

  • Deleting FSharp.Core v9.0 from my global NuGet folder doesn't work - same missing file error message.
  • Replacing the paket-downloaded 9.0 nuget package with one directly from the source at nuget.org. Still the missing file error.
  • Checked paket.lock and paket why. FSharp.Core >=9.0 is not present in any dependency chain.
  • Set FSharp.Core explicitly to an older version in paket.dependencies and ran paket install and restore. Still no luck, my project keeps refering to 9.0. <-- This is the most surprising to me, as I always thought Paket tried to enforce the versions or failed.
  • Set DependencyVersion to Lowest in my NuGet.config file.
  • Referenced an older version of FSharp.Core explicitly in my fsproj files. It compiles, but when I run one of the (Fable-based) projects I get no successful import of /.../.nuget/packages/fsharp.core/9.0.100/lib/netstandard2.0/FSharp.Core.dllstartup - probably because Fable does a dotnet restore that reinstates 9.0 as a dependency.

Note: all builds attempts were both in my IDE (Rider) and with dotnet build.

My best bet now is that a non-Paket managed library has a dependency to FSharp.Core and DependencyVersion Lowest somehow didn't work, resulting in the newly released version of FSharp.Core being used, but I didn't add references lately and I try to keep all my stuff in Paket, so any help is welcome.


Solution

  • OK, I solved it by cleaning all bin and obj directories in the projects and referencing a strict version of FSharp.Core in paket.dependencies. Still weird that FSharp.Core 9 was referenced in the first place...