Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fsharp compilation fails under Mono with an NuGet error

Tags:

nuget

mono

f#

Update. With Matt Ward's help I traced this to a bad config file. The following ~/.config/NuGet/NuGet.Config works for me

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <packageSources>
   <add key="nuget.org" value="https://www.nuget.org/api/v2/" protocolVersion="2" />
 </packageSources>
  <packageSources>
   <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
 </packageSources>
</configuration>

I can do the following without any problems:

/opt/mono/mono-5.2.0.196-tarball/bin/mono ~/nuget.exe install -version 2.6.4 nunit

However, when I try to compile fsharp under the same installation of Mono, I get the following error. This is in the fsharp4 branch. What might I be doing wrong, please? Many thanks.

Project "/dir/src/fsharp/FSharp.Build-proto/FSharp.Build-proto.fsproj" (default target(s)): Target CallFsSrGen: Created directory "obj/proto/./" Tool /dir/src/fsharp/FSharp.Build-proto/../../../lib/bootstrap/4.0/fssrgen.exe execution started with arguments: /dir/src/fsharp/FSharp.Build/FSBuild.txt obj/proto/./FSBuild.fs FSBuild.resx Target BeforeBuild: Executing: mono --runtime=v4.0.30319 /dir/src/fsharp/FSharp.Build-proto/../../../.nuget/NuGet.exe restore packages.config -PackagesDirectory packages Unable to find version '2.6.4' of package 'NUnit'. Unable to find version '2.6.4' of package 'NUnit.Runners'. /dir/src/FSharpSource.targets: error : Command 'mono --runtime=v4.0.30319 /dir/src/fsharp/FSharp.Build-proto/../../../.nuget/NuGet.exe restore packages.config -PackagesDirectory packages' exited with code: 1. Task "Exec" execution -- FAILED Done building target "BeforeBuild" in project

like image 588
John Avatar asked Jul 08 '17 14:07

John


1 Answers

Check what version of NuGet you are using and what NuGet package sources are enabled. Either there no NuGet package sources enabled or you are using a NuGet v2 .exe with a NuGet v3 package source.

If there is no NuGet.Config file that is provided with the FSharp build source code you are using then check the package sources listed in the file ~/.config/NuGet/NuGet.config. I suspect that it only has the v3 package source https://api.nuget.org/v3/index.json which cannot be used with a NuGet.exe (v2). So you would either need to update the nuget.exe to a later version or add the NuGet v2 package source into your NuGet.Config file: https://www.nuget.org/api/v2/

like image 131
Matt Ward Avatar answered Nov 02 '22 22:11

Matt Ward