Did you try make your PCL as nuget and add whole nuget instead of dll one by one ? It should be worked. Like MauiCommunityToolkit it PCL and whe you check the strcture of packe it is simila inside lib folder like output from pcl in bin.
How to add my custom .NET MAUI class library output dlls to .NET MAUI app?
I have created a .NET MAUI class library single project that when built it generates multiple dlls each one inside platform specific folder.
Now I am having difficulties figuring out how to reference this class library dlls inside my .NET MAUI app, when I add them all even if I use Conditions I keep getting error below which is AppHostBuilderExtensions extension method inside my library:
The call is ambiguous between the following methods or properties: 'MyLibrary.Hosting.AppHostBuilderExtensions.ConfigureLibrary'
So what's the best way to reference class library multiple dlls inside MAUI app?
<Reference Include="MyLibrary">
<SpecificVersion>False</SpecificVersion>
<HintPath>MyLibraryOutputPath/MyLibrary.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MyLibrary.Android" Condition="$(TargetFramework.StartsWith('net6.0-android'))">
<SpecificVersion>False</SpecificVersion>
<HintPath>MyLibraryOutputPath/net6.0-android/MyLibrary.Android.dll</HintPath>
<Private>False</Private>
</Reference>
The problem turned out to be with the <Private>False</Private> element, when I removed it from the app references the app compiles and runs fine but I have below 2 issues now:
1- If I changed my library output DLLs names so that each platform has different name like "<LibName>.<PlatformName>.dll" I get below compilation error when using the library from inside XAML files:
MainPage.xaml : XamlC error : Failed to resolve assembly: 'MauiLib1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
My library DLLs names are as below and we need then to have different names because when we distribute them we put then in one folder among other DLLs of our toolkit:
net6.0: MyLibrary.dll
net6.0-android: MyLibrary.Android.dll
net6.0-ios: MyLibrary.iOS.dll
net6.0-windows: MyLibrary.Windows.dll
Any idea how to achieve this?
2- Even if I kept the library output DLLs names identical (without adding platform names) for each platform it compiles and runs BUT when you open the XAML file it shows warning underlines under the types I use from inside my library, any idea why? I even tried to close VS and cleaned my MAUI app generated folders/files but still the types I use from inside the library are highlighted as warnings and I get no intelli-sense for them.
I don't know if I can attach projects here but I couldn't find any option to do that so I uploaded my project to github and below is the link to it for your reference so you can check the above issues on your side:
https://github.com/TamerIrdais/.NET-MAUI-App-With-References-to-MAUI-Class-Library
I am using Microsoft Visual Studio Enterprise 2022 Version 17.3.0 Preview 5.0 but I don't know how to get the MAUI version.