fsharp 编译在 Mono 下失败并出现 NuGet 错误
fsharp compilation fails under Mono with an NuGet error
更新。在 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 分支中。请问我可能做错了什么?非常感谢。
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
检查您使用的 NuGet 版本以及启用了哪些 NuGet 包源。没有启用 NuGet 包源,或者您正在使用带有 NuGet v3 包源的 NuGet v2 .exe。
如果没有随您使用的 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/
更新。在 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 分支中。请问我可能做错了什么?非常感谢。
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
检查您使用的 NuGet 版本以及启用了哪些 NuGet 包源。没有启用 NuGet 包源,或者您正在使用带有 NuGet v3 包源的 NuGet v2 .exe。
如果没有随您使用的 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/