I've created a cross platform library which has 3 platform specific implementations:
- Android
- iOS
- .NET Standard 2.0
I've packed the library with Nuget in a similar vein as the cross platform library project does it.
Now when I create a new Xamarin Forms project and select .NET Standard as the means to share the code, I reference my nuget and try running it in the android simulator, I get:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'SDK.NetStandard, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'SDK.NetStandard.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x0009a] in /Users/builder/data/lanes/5945/342b2ce9/source/monodroid/external/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:229
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in /Users/builder/data/lanes/5945/342b2ce9/source/monodroid/external/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:179
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver, System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x0014a] in <fdfe8f54615a4e2ab24c72dc90da5c64>:0
at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x00237] in <fdfe8f54615a4e2ab24c72dc90da5c64>:0 (blank.Android)
I've double checked and the SDK.NetStandard.dll exists in the nuget package.
I've tested it also with creating a simple console app with .NET Core 2 and the library works property there.
[EDIT]
I've renamed my package from SDK to Matchmore.SDK to lessen the confusion The error looks like this in runtime iOS.
System.IO.FileNotFoundException: Could not load file or assembly 'Matchmore.SDK.NetStandard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
at blankstandard.App..ctor () [0x0001b] in /Users/lmlynik/Projects/blankstandard/blankstandard/App.xaml.cs:15
at blankstandard.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in /Users/lmlynik/Projects/blankstandard/blankstandard.iOS/AppDelegate.cs:26
at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.10.1.178/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.10.1.178/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at blankstandard.iOS.Application.Main (System.String[] args) [0x00001] in /Users/lmlynik/Projects/blankstandard/blankstandard.iOS/Main.cs:17
Also after unpacking the nupkg you can see the DLL is in there.