【发布时间】:2021-07-15 04:42:33
【问题描述】:
我正在尝试在 GNU/Linux 上将程序从 IL 编译为 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
【问题讨论】:
-
@JL0PD 日志说引用是自动添加的...
-
如果你想用 IL 写,看看
Microsoft.NET.Sdk.ILhow-to。它提供了比原始 ilasm 更好的用户体验。如果您使用<PackageReference Include="FSharp.Core" Version="your version" />,我希望它会自动处理装配问题