Succinct description of the issue
I am using .NET Core 2.2 and I cannot update FSharp.Core to the version 4.7.0 in a simple console app.
Steps required to reproduce the problem
mkdir ConsoleAppcd ConsoleAppdotnet new console --language F#dotnet restoredotnet add package "FSharp.Core" -v 4.7.0Expected behavior
The dotnet add package "FSharp.Core" -v 4.7.0 command works and the FSharp.Core package is supposed to be updated to the version 4.7.0
Actual behavior
The dotnet add package "FSharp.Core" -v 4.7.0 command fails:
dotnet add package "FSharp.Core" -v 4.7.0
Writing C:\Users\eperret\AppData\Local\Temp\tmp6078.tmp
info : Adding PackageReference for package 'FSharp.Core' into project 'C:\Users\eperret\Desktop\ConsoleApp\ConsoleApp.fsproj'.
info : Restoring packages for C:\Users\eperret\Desktop\ConsoleApp\ConsoleApp.fsproj...
info : Package 'FSharp.Core' is compatible with all the specified frameworks in project 'C:\Users\eperret\Desktop\ConsoleApp\ConsoleApp.fsproj'.
error: Error while performing Update for package 'FSharp.Core'. Cannot edit items in imported files -
error: Item 'PackageReference' for 'FSharp.Core' in Imported file 'C:\Program Files\dotnet\sdk\2.2.401\FSharp\Microsoft.FSharp.NetSdk.props'.
The version remains 4.6.2:
λ dotnet list package
Project 'ConsoleApp' has the following package references
[netcoreapp2.2]:
Top-level Package Requested Resolved
> FSharp.Core 4.6.2 4.6.2
> Microsoft.NETCore.App (A) [2.2.0, ) 2.2.0
(A) : Auto-referenced package.
Known workarounds
None
Related information
Provide any related information (optional):
.NET Runtime List:
λ dotnet --list-runtimes
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview3-27503-5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
.NET SDK List:
λ dotnet --list-sdks
1.1.13 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
2.2.202 [C:\Program Files\dotnet\sdk]
2.2.401 [C:\Program Files\dotnet\sdk]
OS:
A related issue of mine also occurs on Linux, its description is available here: https://stackoverflow.com/questions/57701519/f-anonymous-records-are-not-supporter-with-net-core-2-2-108
<PackageReference Update="FSharp.Core" Version="4.7.0"/> is what you need to add, otherwise the build will be confused about which FSharp.Core to reference. This is by design w.r.t how the SDK works.
@cartermp thanks!
Before you answered I also found out that adding <FSharpCoreImplicitPackageVersion>4.7.0</FSharpCoreImplicitPackageVersion> to <PropertyGroup> in the *.fsproj was also doing the job, even though it does look like not that official.
I will stick to your answer definitely looks cleaner.
Where in the .csproj file should the line <PackageReference Update="FSharp.Core" Version="4.7.0"/> be added?
I also get a runtime exception when calling into a .net core 2.2 Fsharp library compiled with multitarget <TargetFrameworks>net45;netcoreapp2.2</TargetFrameworks> from a .net framework 4.7.2 web app.
Exception is: System.IO.FileLoadException could not load fsharp.core 4.4.0.0
<PackageReference Update="FSharp.Core" Version="4.7.0"/> is an Item, so inside of an ItemGroup.
Note that this:
I also get a runtime exception when calling into a .net core 2.2 Fsharp library compiled with multitarget
net45;netcoreapp2.2 from a .net framework 4.7.2 web app.
Is not supported. .NET Framework apps cannot reference .NET Core apps.
Probably also need to set DisableImplicitFsharpCore to true
Phillip Carter notifications@github.com schrieb am Sa., 1. Feb. 2020,
15:36:
is an Item, so
inside of an ItemGroup.Note that this:
I also get a runtime exception when calling into a .net core 2.2 Fsharp
library compiled with multitarget net45;netcoreapp2.2 from a .net framework
4.7.2 web app.Is not supported. .NET Framework apps cannot reference .NET Core apps.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/dotnet/fsharp/issues/7464?email_source=notifications&email_token=AAAOANHJ2ZSLJGR46NAUQ3DRAWCHBA5CNFSM4ISAVSEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKQ6QKI#issuecomment-581036073,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAOANEQ6PCGUL4W45FJMS3RAWCHBANCNFSM4ISAVSEA
.
Nope, that one's only needed if you're not using Packageference Update.
Most helpful comment
<PackageReference Update="FSharp.Core" Version="4.7.0"/>is what you need to add, otherwise the build will be confused about which FSharp.Core to reference. This is by design w.r.t how the SDK works.