使用Mono编译F#时出现NuGet错误。

6

更新。在Matt Ward的帮助下,我找到了这个问题的原因是一个坏的配置文件。以下的~/.config/NuGet/NuGet.Config对我有效。

<?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>

我可以毫无问题地完成以下任务:

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

然而,当我尝试在相同的Mono安装下编译fsharp时,我会遇到以下错误。这是在fsharp4分支中。请问我可能做错了什么呢?非常感谢。
引用块: 项目“/ dir / src / fsharp / FSharp.Build-proto / FSharp.Build-proto.fsproj”(默认目标): 目标CallFsSrGen:已创建目录“ obj / proto / ./” 工具/dor/src/fsharp/FSharp.Build-proto/../../../lib/bootstrap/4.0/fssrgen.exe 执行时使用参数: /dor/src/fsharp/FSharp.Build/FSBuild.txt obj/proto/./FSBuild.fs FSBuild.resx 目标BeforeBuild:正在执行:mono --runtime = v4.0.30319 /dir/src/fsharp/FSharp.Build-proto/../../../.nuget/NuGet.exe restore packages.config -PackagesDirectory packages 无法找到版本为'2.6.4'的软件包'NUnit'。 无法找到版本为'2.6.4'的软件包'NUnit.Runners'。/dir/src/FSharpSource.targets: error : 命令'mono --runtime=v4.0.30319 /dir/src/fsharp/FSharp.Build-proto/../../../.nuget/NuGet.exe restore packages.config -PackagesDirectory packages'退出代码为:1。 任务“Exec”执行--FAILED在项目中完成构建目标“BeforeBuild”。

1
你是否正试图从命令行编译? - N_A
1
没错。我正在使用通常的基于makefile的构建方式。它在过去的同一台计算机上运行良好(在旧版Mono下,并且可能使用不同版本的f# git树)。 - John
检查您正在使用的NuGet版本以及启用了哪些NuGet软件包源。我的猜测是,要么您没有启用任何NuGet软件包源,要么您正在使用一个NuGet v2 .exe与一个NuGet v3软件包源。 - Matt Ward
@Matt Ward:非常感谢。编译f#时使用的NuGet版本是2.8.50506.491。在命令行上运行的版本是4.1.0.2450。您有什么提示可以告诉我应该在哪里放置软件包源,以便与2.8兼容?fsharp构建似乎没有任何配置选项来选择特定版本的nuget/nunit。再次感谢。 - John
如果您使用的 FSharp 构建源代码没有提供 NuGet.Config 文件,则应检查文件 ~/.config/NuGet/NuGet.config。我怀疑它只有 v3 包源:https://api.nuget.org/v3/index.json。因此,您需要更新 nuget.exe 到较新版本或将 NuGet v2 包源添加到您的 NuGet.Config 文件中:https://www.nuget.org/api/v2/ - Matt Ward
显示剩余2条评论
1个回答

2
检查您正在使用的 NuGet 版本以及启用了哪些 NuGet 包源。要么没有启用 NuGet 包源,要么您正在使用一个 NuGet v2 .exe 与一个 NuGet v3 包源。
如果 FSharp 构建源代码中没有提供 NuGet.Config 文件,则请检查文件 ~/.config/NuGet/NuGet.config 中列出的包源。我怀疑它只有 v3 包源 https://api.nuget.org/v3/index.json,无法与 NuGet.exe (v2) 一起使用。因此,您需要更新 nuget.exe 到较新版本或将 NuGet v2 包源添加到您的 NuGet.Config 文件中: https://www.nuget.org/api/v2/。

再次感谢您的帮助。 - John

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接