6
votes

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

1
Are you trying to compile from the command line? - N_A
Correct. I am using the the usual makefile-based build. It worked on the same computer in the past (under an older Mono, and with possibly a different version of the f# git tree). - John
Check what version of NuGet you are using and what NuGet package sources are enabled. My guess is that either you have no NuGet package sources enabled or you are using a NuGet v2 .exe with a NuGet v3 package source. - Matt Ward
@Matt Ward: Many thanks. The version of NuGet used when compiling f# is 2.8.50506.491. The version that works on the command line is 4.1.0.2450. Any hints on how and where I should put package sources that would work with 2.8? The fsharp build does not seem to have any configuration options to select a particular version of nuget/nunit. Thanks again. - John
If there is no NuGet.Config file that is provided with the FSharp build source code you are using then I would check the file ~/.config/NuGet/NuGet.config. I suspect that it only has the v3 package source: https://api.nuget.org/v3/index.json. 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/ - Matt Ward

1 Answers

2
votes

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/