1

Q: How to create F# Console Application targeting .NET Framework 4.5.2. in Visual Studio 2019? Is that even possible?

Selected F# + Windows + Console:

enter image description here

Selected .NET Framework 4.5.2.:

enter image description here

When then project gets created it has no target framework:

enter image description here

and in Solution Explorer it looks like this:

enter image description here

and the following message is displayed :

enter image description here

Q: Which .NET SDK do I need to be able to create F# Console Application targeting .NET Framework 4.5.2.?


Based on comment from Bent Tranberg I created Console Application which used target Framework 4.7.2 and edited the project file:

<TargetFramework>net472</TargetFramework> was changed to <TargetFramework>net452</TargetFramework>

And then the NuGet package FSharp.Core was downgraded from version 5.0.0 to version 4.5.2.

On my machine where Visual Studio 2019 is installed I see this version of .NET SDK:

enter image description here

I used FSharp.Core.4.5.2 which seems to work so far.

But here the minimum F# language version and the minimum FSharp.Core package version can be found.

Q: My F# Interactive shows F# 5.0 so I should use FSharp.Core.5.0.0 but that doesn't seem to work with .NET Framework 4.5.2 so what to do?

Daniel Dušek
  • 13,683
  • 5
  • 36
  • 51
  • I don't think the concept of an SDK exists in the .NET Framework world. I would start the VS Installer and look for a way to select .NET Framework 4.5.2 or any 4.x.x. there - to make sure you've got at least one of them. If you must run on .NET Framework 4.5.2, I still think there's a possibility to develop with a later - or earlier - .NET Framework 4.x.x in VS and run the appl in 4.5.2. You are really sure you need Framework at all? – Bent Tranberg Jan 07 '23 at 14:05
  • I normally use .NET 4.5.2. with C# in VS 2019. Now I would like to check F# but am not able to create even simple console application. – Daniel Dušek Jan 07 '23 at 14:08
  • Is F# checked in the VS Installer? The default is that it is not checked, but I assume you have checked it since you have F# in that screenshot above. I'm going to see if I can duplicate what you try to do in my VS 2019. – Bent Tranberg Jan 07 '23 at 14:49
  • Yes F# is checked in VS installer, thanks! – Daniel Dušek Jan 07 '23 at 14:50
  • Ok, I have the same error. When I look in the project file, I am missing something. I had expected an entry for the target framework there. Try to create another project for the latest framework, and see if that works. If it does, then steal the correct entry and change the version. I'll try it too. – Bent Tranberg Jan 07 '23 at 14:55
  • Yes that seems to work! In project file I see net472. Will try to change to 4.5.2. as that framework version I have to use now. – Daniel Dušek Jan 07 '23 at 15:00
  • If along the way you get an error about project.assets.json not having a target, just do a Clean in VS, and then Rebuild. I now have `net48` in the project file, and it works, but net452 there will cause compile errors. Maybe you are luckier. – Bent Tranberg Jan 07 '23 at 15:03
  • After changing the version to 452 I see this error: Package FSharp.Core 5.0.0 is not compatible with net452 (.NETFramework,Version=v4.5.2). Package FSharp.Core 5.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0). So I need higher version of ackage FSharp.Core? – Daniel Dušek Jan 07 '23 at 15:05
  • Maybe we can change the FSharp.Core version explicitly to a lesser one, from NuGet. – Bent Tranberg Jan 07 '23 at 15:07
  • 1
    Yes that seems to work, changed FSharp.Core nuget package to version 4.5.2. The Console Application seems to work now! Summarize the comment to an short answer I will accept it, thanks! – Daniel Dušek Jan 07 '23 at 15:09
  • I wouldn't mind if you created a brief answer here, describing how we arrived at a solution. Just two or three sentences should be enough I guess. Others might run into the same problem. Ooops! See now that you're asking me. No time. – Bent Tranberg Jan 07 '23 at 15:13

0 Answers0