3

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.

3
  • 1
    you don't have to use ionide template to create F# console project. Just use .net core cli then open the directory with ionide. learn.microsoft.com/en-us/dotnet/fsharp/get-started/…
    – ekim boran
    Apr 8, 2018 at 17:02
  • 1
    yeah, it's an annoying problem with poor error messages.. have you installed the referenceassemblies-pcl package?
    – eug
    Apr 9, 2018 at 1:55
  • Yeah - got that installed, a bit older version though: apt-cache policy referenceassemblies-pcl referenceassemblies-pcl: Installed: 2014.04.14-1xamarin4+ubuntu1604b1 Candidate: 2014.04.14-1xamarin4+ubuntu1604b1 I've tried changing my project's target framework to e.g. net45 (anything that existed in 2014), but that didn't help either.
    – LA.27
    Apr 9, 2018 at 21:41

3 Answers 3

3

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.

2
  • Thanks - that works in fact better than my solution, as it enables IntelliSense in VS Code. Good stuff!
    – LA.27
    Apr 27, 2018 at 22:49
  • Is this answer still current? Oct 10, 2019 at 23:52
1

The problem is that you don't have .NET Framework Reference Assemblies. The compiler needs them to in order to know about the .NET Framework APIs your code references.

The good news is that you can get these reference assemblies via nuget

The bad news is that it's not yet published on nuget.org, so you need to add the myget feed to your project

To fix this, add the following to your fsproj

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
    <PackageReference 
          Include="Microsoft.TargetingPack.NETFramework.v4.6.1" 
          Version="1.0.1" ExcludeAssets="All" PrivateAssets="All" />
</ItemGroup>

Then you need to add a Nuget.Config file to your project

<configuration>
 <packageSources>
    <add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
 </packageSources>
</configuration>

With these in place you should be able to build net461 exes and dlls on Linux

1
  • Thanks - I'll give it a go later on. I'll need to modify this solution a bit, as I use paket, so there's no Nuget.Cofig. Anyway I think this doesn't change much.
    – LA.27
    Apr 27, 2018 at 16:06
0

Thanks, guys for the responses - let me just post something that I found out on my own. I worked out that adding the following line to my build.sh script does the deal as well: export FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.5/ I guess this is similar to what Chester said, but done in a bit different way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.