3
votes

I'm trying to create portable F# library but it needs to target .NET 4.0 (company policy is that all portable libraries need to be compatible with Windows XP).

When I create (Visual Studio 2013) new project there is an option "Portable Library (Legacy)" with description saying "A project for creating an F# library (.dll) that can run on .NET Framework 4.0 and higher, Windows Store and Silverlight 5".

The problem is, when the project is actually created. When I go to project's properties "Target Framework" is set to ".NET Portable Subset (.NET Framework 4.5, Silverlight 5, Windows 8)".

I tried changing F# runtime version from 3.1 to 3.0 but it does not change anything. "3.0" and "3.1" are the only options. What happened to "2.0"? Am I missing something?

EDIT: It seems like Grzegorz is right. I've created this F# PCL which is saying ".NET 4.5" and referenced it from .NET 4.0 C# application. No problems were reported.

Then, to be sure, I also referenced it from 3.5 application and... no problems were reported during compilation either, but it was crashing on runtime. So to be sure, I ran the "potentially 4.0" application on XP and it worked, which may be interpreted as: "Yes, F# PCL does not depend on 4.5 even it it says so".

Make it an answer so I can tick it.

1
It seems that there's a problem with user interface or the project template. If You'll go to project folder and open the project file in an external editor You'll see that TargetFrameworkVersion is set to v4.0.Grzegorz Sławecki
I just doublechecked that the template file for this has the framework version hardcoded so You should just try to build Your lib and test whether it works with 4.0. Please let me know it this works, if so then I'll post this as an answer.Grzegorz Sławecki

1 Answers

1
votes

The template file for "Portable Library (Legacy)" has TargetFrameworkVersion hardcoded as v4.0. If You'll create a project with this template it'll in fact target 4.0 version.

Probably, there's a bug in UI that keeps displaying target framework as 4.5 while in reality it uses previous one.

To be strict, the issue is related to legacy Portable Library. The non-legacy version seems to work correctly in forcing framework to be in 4.5 version.

update: I submitted an issue about this to Visual F# Tools team: https://visualfsharp.codeplex.com/workitem/95