Share via

Multi-targeting Library for Xamarin

l_h_t 21 Reputation points
2021-06-13T16:49:15.847+00:00

Hi. I'm trying to create a multiple-targeting library for Xamarin(Android, IOS and UWP.) I examined project files of some multi-targeting xamarin libraries. (Such as Rg.Plugins.Popup, Xamarin.Essentials, MvvmCross) and edited the csproj file of my library(XamTemel.Ortak) like this.

<Project Sdk="MSBuild.Sdk.Extras/3.0.22">  
  <PropertyGroup>  
    <TargetFrameworks>netstandard2.0;Xamarin.iOS10;monoandroid10.0;</TargetFrameworks>  
    <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);uap10.0.17763;</TargetFrameworks>  
    <DebugType>portable</DebugType>  
    <Configurations>Debug;Release</Configurations>  
  </PropertyGroup>  
  <PropertyGroup Condition=" '$(Configuration)'=='Debug' ">  
    <DebugSymbols>true</DebugSymbols>  
  </PropertyGroup>  
  <PropertyGroup Condition=" '$(Configuration)'=='Release' And '$(OS)' == 'Windows_NT' ">  
    <!-- sourcelink: Declare that the Repository URL can be published to NuSpec -->  
    <PublishRepositoryUrl>true</PublishRepositoryUrl>  
    <!-- sourcelink: Embed source files that are not tracked by the source control manager to the PDB -->  
    <EmbedUntrackedSources>true</EmbedUntrackedSources>  
    <!-- sourcelink: Include PDB in the built .nupkg -->  
    <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>  
  </PropertyGroup>  
  <ItemGroup>  
    <Compile Remove="Platforms\**\*.cs" />  
    <None Include="Platforms\**\*.cs" />  
  </ItemGroup>  
  <ItemGroup Condition=" $(TargetFramework.StartsWith('monoandroid')) ">  
    <None Remove="Platforms\Android\**\*.cs" />  
    <None Remove="Platforms\Xamarin\**\*.cs" />  
    <Compile Include="Platforms\Android\**\*.cs" />  
    <Compile Include="Platforms\Xamarin\**\*.cs" />  
    <AndroidResource Include="Resources\**\*.xml" SubType="Designer" Generator="MSBuild:UpdateAndroidResources" />  
    <AndroidResource Include="Resources\**\*.json" Generator="MSBuild:UpdateAndroidResources" />  
  </ItemGroup>  
  
  <ItemGroup>  
    <PackageReference Include="ColorPicker.Xamarin.Forms" Version="1.3.4.11" />  
  </ItemGroup>  
  
  
</Project>  
  
  

As you can see I am going to put platform renderers in Platform/Android-IOS-UWP etc. Not this works fine on Android. But ColorPicker library gives me this error on UWP.

105145-available.png

I don't understand why it cannot find ColorPicker. Version number seems okay. What am i doing wrong?

Here is the sample solution.

https://drive.google.com/file/d/1PnqFyzDmTBom6GH9YVdbyBvNwikitYlC/view?usp=sharing

Developer technologies | .NET | Xamarin

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.