What's the best practice for using F# with Central Package Management
I noticed my FSProj broke when enabling CPM.
I see that's because the implicit reference to FSharp.Core is not added in this case.
What am I supposed to do to fix this? Should I be adding a PackageReference to all fsprojs and listing the PackageVersion in my central Directory.Packages.props? Should I use the FSCorePackageVersion that's defined by the SDK?
@ericstj that is actually a very interesting question.
Ideally the compiling SDK should determine the FSharp.Core package, because the compiler and F# Core are co-developed, new language features almost always rely on the latest FSharp.Core.
If you want to use CPM set DisableImplicitFSharpCoreReference to true. and add a specific FSharp.Core to load in your project file. A good starting version is the value of FSCorePackageVersion which does match the version shipped with that SDK.
In agreement with @KevinRansom - here is the practice I follow:
In Directory.Packages.props:
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="FSharp.Core" Version="9.0.300" />
</ItemGroup>
</Project>
In Directory.Build.props:
<Project>
<PropertyGroup>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" />
</ItemGroup>
</Project>
@Lanayx This doesn't have to be in a Directory.Build.props it can be but shouldn't be necessary. <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
@KevinRansom agree, but it makes a big sense for Central Package Management. The idea is to manage all packages centrally including FSharp.Core and avoid duplicating this lines in every project.
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
This is an optional line) https://github.com/dotnet/fsharp/pull/13920
<PackageReference Include="FSharp.Core" />
There may be non-fsharp projects, it is better to add a check for fsharp)