我正在尝试将一个程序从 IL 编译为 GNU/Linux 上的 exe,但无法解释如何动态链接 FSharp.Core.dll
。我尝试将其复制并粘贴到构建 .exe 的同一目录中,但没有成功。我实际上不确定问题出在哪里:在我的 .il 代码中、在我的两个 JSON 文件中或在环境中。
$ dotnet --list-sdks
5.0.301 [/usr/share/dotnet/sdk]
我使用 /usr/bin/ilasm testRepeat.il
编译并使用 /usr/bin/dotnet ./testRepeat.exe
运行它。编译输出表示自动添加对 FSharp.Core 的引用
$ /usr/bin/ilasm testRepeat.il
Assembling 'testRepeat.il' , no listing file, to exe --> 'testRepeat.exe'
testRepeat.il : Warning -- Reference to undeclared extern assembly 'System.Runtime', adding.
testRepeat.il : Warning -- Reference to undeclared extern assembly 'FSharp.Core', adding.
testRepeat.il : Warning -- Reference to undeclared extern assembly 'System.Private.CoreLib', adding.
testRepeat.il : Warning -- Reference to undeclared extern assembly 'System.Console', adding.
Operation completed successfully
$ dotnet ./testRepeat.exe
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'FSharp.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
[1] 140195 IOT instruction (core dumped) dotnet ./testRepeat.exe
.il 和 .json 文件是 here
答案 0 :(得分:0)
看起来所有依赖项都应该在“...deps.json”文件中提及。我需要添加以下内容才能使其工作:
{
...
"targets": {
...
"FSharp.Core/5.0.0": {
"runtime": {
"lib/netstandard2.0/FSharp.Core.dll": {
"assemblyVersion": "5.0.0.0",
"fileVersion": "5.0.20.50704"
}
}
}
}
},
...