mono / Embeddinator-4000

Tools to turn .NET libraries into native libraries that can be consumed on Android, iOS, Mac, Linux and other platforms.
MIT License
758 stars 95 forks source link

objcgen does not support netcore assemblies by default #777

Open delebedev opened 4 years ago

delebedev commented 4 years ago

Steps to Reproduce

I've created vanilla netcore app with "hello world" class, built it with Visual Studio and trying to use objcgen from terminal:

~/.nuget/packages/embeddinator-4000/0.4.0/tools/objcgen net-embedding/bin/Debug/netcoreapp3.1/net-embedding.dll --out=out --platform=macOS-modern --abi=x86_64 --nativeexception --compile --debug --target=framework
Symbol file /Users/denis.lebedev/.nuget/packages/embeddinator-4000/0.4.0/tools/IKVM.Reflection.pdb doesn't match image /Users/denis.lebedev/.nuget/packages/embeddinator-4000/0.4.0/tools/IKVM.Reflection.dll
Parsing assemblies...
    Parsed 'net-embedding/bin/Release/netcoreapp3.1/net-embedding.dll'
Processing assemblies...
error EM0013: Can't find the assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a', referenced by 'net-embedding, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Debug Log:
Processing: 1 assemblies
Processing Assembly: net-embedding

Expected Behavior

Framework is built

Actual Behavior

No framework

Environment

macos 10.15.5 Visual Studio 8.6.5 objcgen 0.4.0

chamons commented 4 years ago

So netcoreapp3.1 suggests this is a .net core application, and I suspect that Embeddinator is not pulling in the various netcore facades and dependencies.

You may be able to hack around this by passing the other assemblies to objcgen in the same invocation, but this is a limitation (we don't support netcore directly yet).

delebedev commented 4 years ago

@chamons I actually tried it with netstandard2.1 too, got

error EM0013: Can't find the assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51', referenced by 'embeddinator-test, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

You may be able to hack around this by passing the other assemblies to objcgen in the same invocation

Would greatly appreciate an example command to to do so

christosk92 commented 3 years ago

@delebedev I had a similar issue where it couldn't find newtonsoft.json I fixed this by adding:

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> to my csproj file and then rebuilding!