2

I have an existing F# / Mono / paket / fake project under Linux that used to compile correctly.

I updated mono using apt-get and now my project won't compile.

It can't find the two referenced packages : MathNet.Numerics and Newtonsoft.Json.

Here's what I'm getting when building the project:

Primary reference "MathNet.Numerics".
/usr/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(1980,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "MathNet.Numerics". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/bleakcabal/Documents/projects/genesis/genesis/genesis/genesis.fsproj]
          For SearchPath "{TargetFrameworkDirectory}".
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.5/MathNet.Numerics.winmd", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.5/MathNet.Numerics.dll", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.5/MathNet.Numerics.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.5-api/MathNet.Numerics.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.5-api/MathNet.Numerics.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.5-api/MathNet.Numerics.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.5-api/Facades/MathNet.Numerics.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.5-api/Facades/MathNet.Numerics.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.5-api/Facades/MathNet.Numerics.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.5-api/Facades/MathNet.Numerics.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.5-api/Facades/MathNet.Numerics.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.5-api/Facades/MathNet.Numerics.exe", but it didn't exist.
          For SearchPath "{GAC}".
          Considered "MathNet.Numerics", which was not found in the GAC.
          For SearchPath "{RawFileName}".
          Considered treating "MathNet.Numerics" as a file name, but it didn't exist.
          For SearchPath "/home/bleakcabal/Documents/projects/genesis/build/".
          Considered "/home/bleakcabal/Documents/projects/genesis/build/MathNet.Numerics.winmd", but it didn't exist.
          Considered "/home/bleakcabal/Documents/projects/genesis/build/MathNet.Numerics.dll", but it didn't exist.
          Considered "/home/bleakcabal/Documents/projects/genesis/build/MathNet.Numerics.exe", but it didn't exist.

The file resides in a packages folder in my project (which I created using Ionide-fsharp with VS code using paket and fake) but this folder is not appearing in the error message.

I am getting the exact same message for Newtonsoft.Json.

Here is my paket.dependencies file:

source https://www.nuget.org/api/v2

nuget FAKE
nuget FSharp.Core
nuget MathNet.Numerics
nuget Newtonsoft.Json

My paket.lock file is too long to post but here are the relevant parts:

MathNet.Numerics (3.19)
      TaskParallelLibrary (>= 1.0.2856) - framework: net35

Newtonsoft.Json (10.0.2)
      Microsoft.CSharp (>= 4.3) - framework: netstandard10, >= netstandard13
      NETStandard.Library (>= 1.6.1) - framework: netstandard10, >= netstandard13
      System.ComponentModel.TypeConverter (>= 4.3) - framework: netstandard10, >= netstandard13
      System.Runtime.Serialization.Formatters (>= 4.3) - framework: >= netstandard13
      System.Runtime.Serialization.Primitives (>= 4.3) - framework: netstandard10, >= netstandard13
      System.Xml.XmlDocument (>= 4.3) - framework: >= netstandard13

Here is an excerpt from one of my multiple .fsproj files that reference these packages:

...
<Reference Include="MathNet.Numerics" />
<Reference Include="Newtonsoft.Json" />
...
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v3.5'">
  <ItemGroup>
    <Reference Include="MathNet.Numerics">
      <HintPath>..\..\packages\MathNet.Numerics\lib\net35\MathNet.Numerics.dll</HintPath>
      <Private>True</Private>
      <Paket>True</Paket>
    </Reference>
  </ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2' Or $(TargetFrameworkVersion) == 'v4.6.3' Or $(TargetFrameworkVersion) == 'v4.7')">
  <ItemGroup>
    <Reference Include="MathNet.Numerics">
      <HintPath>..\..\packages\MathNet.Numerics\lib\net40\MathNet.Numerics.dll</HintPath>
      <Private>True</Private>
      <Paket>True</Paket>
    </Reference>
  </ItemGroup>
</When>

If I do mono --version I get the following:

Mono JIT compiler version 5.0.1.1 (2017-02/5077205 Thu May 25 09:16:53 UTC 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com

I tried using the following commands but to no avail: .paket/paket.exe restore, .paket/paket.exe install, .paket/paket.exe outdated.

Gilles
  • 5,269
  • 4
  • 34
  • 66

2 Answers2

1

To run paket, you will need to run

$ mono paket.exe install

If you still have trouble with missing assemblies or wonky references, try either

$ apt-get install mono-dev

or

$ apt-get install mono-complete

For more info on Mono installation, take a look at http://www.mono-project.com/download/#download-lin

Taylor Fraley
  • 99
  • 2
  • 6
  • Thanks for the help. As I had mentionned in my question I had already tried paket.exe install. I hadn't tried to to reinstall the mono pacakge so I did. apt-get install didn't do anything since they were already up to date but I tried with the --reinstall switch to force reinstallation but got the same results. – Gilles Jun 09 '17 at 20:44
  • You could try `paket.exe update --redirects` ; Also, it looks like you may have an extra `` for both of those packages in your fsproj. I'm honestly not sure if that's a problem, but you could try commenting out the two that are not inside `` sections. – Taylor Fraley Jun 10 '17 at 00:13
  • Ah still no luck but +1 for the help. I'll try creating a new project with these same dependencies and compare the .fsproj and paket files. – Gilles Jun 10 '17 at 00:27
1

I ended up doing a paket.exe update --redirects like @TaylorFraley recommended which modified some files.

Then using the paket ionide plugin I removed both packages from my solution.

I then searched the solution for anything remaining about those two packages (two Reference Include in my .fsproj) which I then manually deleted.

I reinstalled the packages using the paket Ionide plugin again and everything worked.

So the solution would be to delete everything and add them again. Not sure why the paket update didn't work though.

Gilles
  • 5,269
  • 4
  • 34
  • 66