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

Link assembly error related to Entity Framework Core reference in the input library #694

Open jnajerasc opened 6 years ago

jnajerasc commented 6 years ago

Embeddinator-4000 returns the following error when processing a Xamarin library that references EF Core:

error MM2001: Could not link assemblies. Reason: Error processing method: 'System.Void EFCoreSampleLibrary1.BloggingContext::OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder)' in assembly: 'EFCoreSampleLibrary1.dll'

Steps to Reproduce

Refer to the attached zip file, which contains sample code that demonstrates this issue.

The sample code contains three projects: a .NET Standard 2.0 library that contains the EF Core tutorial code (https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite); a .NET Core 2.1 application that creates a library object and uses it to run the database tutorial code; a Xamarin library that acts as a wrapper of the .NET Standard library so an Objective-C app can invoke the EF Core tutorial code, assuming a successful code generation by Embeddinator-4000.

As part of the EF Core setup, I ran migration on the library project and referenced the startup project:

dotnet ef migrations add InitialCreate --startup-project ../EFCoreSampleNetCoreApp1/EFCoreSampleNetCoreApp1.csproj

Rather than running the 'dotnet ef database update' command, the program invokes the Migrate method of DbContext at runtime.

After building the Release configuration successfully in Visual Studio for Mac, I ran Embeddinator-4000 and had to resolve 10 errors related to missing internal dependencies in bin/Release. One such error was:

error MM2002: Failed to resolve "Microsoft.EntityFrameworkCore.DbContext" reference from "Microsoft.EntityFrameworkCore, Version=2.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60"

These are the libraries that I had to manually copy into bin/Release from my local NuGet cache to get past the Embeddinator-4000 "Failed to resolve" errors:

Microsoft.EntityFrameworkCore.Abstractions.dll (2.1.2, netstandard2.0) Microsoft.EntityFrameworkCore.dll (2.1.2, netstandard2.0) Microsoft.EntityFrameworkCore.Relational.dll (2.1.2, netstandard2.0) Microsoft.Extensions.Caching.Abstractions.dll (2.1.1, netstandard2.0) Microsoft.Extensions.DependencyInjection.Abstractions.dll (2.1.1, netstandard2.0) Microsoft.Extensions.Logging.Abstractions.dll (2.1.1, netstandard2.0) Microsoft.Extensions.Primitives.dll (2.1.1, netstandard2.0) Remotion.Linq.dll (2.2.0, netstandard1.0) System.Diagnostics.DiagnosticSource.dll (I copied 4.4.1, netstandard1.3 -- error referred to assembly version 4.0.3.0) System.Interactive.Async.dll (I copied 3.2.0, netstandard2.0 -- error referred to assembly version 3.0.3000.0)

At this point, I get the link assembly error.

Expected Behavior

I expect a successful code generation of the sample Xamarin library by Embeddinator-4000.

Actual Behavior

error MM2001: Could not link assemblies. Reason: Error processing method: 'System.Void EFCoreSampleLibrary1.BloggingContext::OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder)' in assembly: 'EFCoreSampleLibrary1.dll'

Environment

~/.nuget/packages/embeddinator-4000/0.4.0/tools/objcgen -version
Symbol file /Users/me/.nuget/packages/embeddinator-4000/0.4.0/tools/IKVM.Reflection.pdb doesn't match image /Users/me/.nuget/packages/embeddinator-4000/0.4.0/tools/IKVM.Reflection.dll
Embeddinator-4000 v0.1 (0.4: 7664197)

macOS 10.13.6 (High Sierra)

Build Logs

This is the output of Embeddinator-4000 after copying all internally-referenced libraries into bin/Release:

MacBook:EFCoreSample1 me$ ~/.nuget/packages/embeddinator-4000/0.4.0/tools/objcgen bin/Release/EFCoreSample1.dll  --target=framework --platform=macOS-modern --abi=x86_64 --outdir=output -c --debug
Symbol file /Users/me/.nuget/packages/embeddinator-4000/0.4.0/tools/IKVM.Reflection.pdb doesn't match image /Users/me/.nuget/packages/embeddinator-4000/0.4.0/tools/IKVM.Reflection.dll
Parsing assemblies...
    Parsed 'bin/Release/EFCoreSample1.dll'
Processing assemblies...
    1 types found
Generating binding code...
    Generated: output/bindings.h
    Generated: output/bindings-private.h
    Generated: output/bindings.m
    Generated: output/bindings.xml
    Generated: output/embeddinator.h
    Generated: output/glib.h
    Generated: output/mono_embeddinator.h
    Generated: output/mono-support.h
    Generated: output/objc-support.h
    Generated: output/glib.c
    Generated: output/mono_embeddinator.c
    Generated: output/objc-support.m
    Generated: output/Make.config
Compiling binding code...
Found Mono 5.10.1.57 (between 5.4.1.7 and 5.4.1.7)
Found Xamarin.Mac 4.2.1.28 (between 4.0.0.215 and 4.0.0.215)
    xcode-select -p
    xcrun clang -g -O0 -fobjc-arc -ObjC -Wall -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=10.7 -I/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/include -DXAMARIN_MAC -DMONO_EMBEDDINATOR_DLL_EXPORT  -c output/glib.c -o output/x86_64/glib.o 
    xcrun clang -g -O0 -fobjc-arc -ObjC -Wall -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=10.7 -I/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/include -DXAMARIN_MAC -DMONO_EMBEDDINATOR_DLL_EXPORT  -c output/mono_embeddinator.c -o output/x86_64/mono_embeddinator.o 
    xcrun clang -g -O0 -fobjc-arc -ObjC -Wall -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=10.7 -I/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/include -DXAMARIN_MAC -DMONO_EMBEDDINATOR_DLL_EXPORT  -c output/objc-support.m -o output/x86_64/objc-support.o 
    xcrun clang -g -O0 -fobjc-arc -ObjC -Wall -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=10.7 -I/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/include -DXAMARIN_MAC -DMONO_EMBEDDINATOR_DLL_EXPORT  -c output/bindings.m -o output/x86_64/bindings.o 
    xcrun ar cru output/x86_64/EFCoreSample1.a output/x86_64/glib.o output/x86_64/mono_embeddinator.o output/x86_64/objc-support.o output/x86_64/bindings.o 
    xcrun --show-sdk-version --sdk macosx
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/bin/mmp --output=/Users/me/Projects/EFCoreSample1/EFCoreSample1/output/MacOSX/EFCoreSample1 --arch=x86_64 --sdkroot /Applications/Xcode.app --minos 10.7 --embeddinator /Users/me/Projects/EFCoreSample1/EFCoreSample1/bin/Release/EFCoreSample1.dll -a:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/Xamarin.Mac.dll --sdk 10.13 --linksdkonly --xml=output/bindings.xml --registrar:static --cache /Users/me/Projects/EFCoreSample1/EFCoreSample1/output/MacOSX/build-cache --debug -p --target-framework Xamarin.Mac,Version=v2.0,Profile=Mobile "--link_flags=-force_load /Users/me/Projects/EFCoreSample1/EFCoreSample1/output/MacOSX/EFCoreSample1.a" 
Xamarin.Mac 4.2.1
error MM2001: Could not link assemblies. Reason: Error processing method: 'System.Void EFCoreSampleLibrary1.BloggingContext::OnConfiguring(Microsoft.EntityFrameworkCore.DbContextOptionsBuilder)' in assembly: 'EFCoreSampleLibrary1.dll'

Example Project (If Possible)

EFCoreSample1.zip

jcapellman commented 6 years ago

@mandel-macaque

Is there any eta on this getting fixed?

mandel-macaque commented 6 years ago

@jcapellman sorry, but there is no ETA at the moment, we are triaging, identifying issues and will get back to you. But I do not expect it to be any time soon, sorry :(