Skip to content
Advertisement

F# on Linux – targeting net4xx

I’ve got both mono (5.10.1.20) and dotnet core (2.1.4) installed on my Linux Mint (18.3) machine.

I want to create a project using VS Code Ionide: Ctrl+Shift+P -> F#: New Project -> console. This goes without problems. However, when I try to build it, I get:

error MSB3644: The reference assemblies for framework “.NETFramework,Version=v4.6.1” were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed.

I take a look at my .fsproj file and indeed – it says:

<TargetFramework>net461</TargetFramework>

However, I found some articles online where people claim to be able to build this without problems (e.g. Suave-Music-Store tutorial found here:

https://legacy.gitbook.com/book/theimowski/suave-music-store/details )

I’m surely missing something here. So my question is: what exactly (and how to make this work) ?

PS: I was able to hack this a little bit by changing the target framework to “netcoreapp2.0”, but still I pretty sure the template should work out of the box.

Advertisement

Answer

The other answer is to set the FrameworkPathOverride MsBuild parameter. The assemblies you need are already included in Mono, and you can tell the compiler where to find them by setting FrameworkPathOverride. You can easily do this by including the netfx.props file here: https://github.com/fsprojects/FSharp.TypeProviders.SDK/blob/master/netfx.props. You’d download this to your repo and then add the following line to all of your project files:

<Import Project="..netfx.props" />

This is what several projects do. Once either MSBuild changes to look here as well, or an official nuget package comes out, I expect many FSharp projects to switch to one of those methods.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement