Skip to content

Instantly share code, notes, and snippets.

@Juansero29
Last active May 18, 2019 02:47
Show Gist options
  • Save Juansero29/593842352a2b2109b3a08371d0d1bdf5 to your computer and use it in GitHub Desktop.
Save Juansero29/593842352a2b2109b3a08371d0d1bdf5 to your computer and use it in GitHub Desktop.
Example of a Multi-targeted .NET Standard Library for Xamarin. This library targets .NET Standard 2.0, Xamarin.iOS and Xamarin.Android, it is here as a reference
<Project Sdk="MSBuild.Sdk.Extras/2.0.24">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<!--Don't auto add files for me, I will tell you how to do it -->
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<!--The frameworks we're targeting-->
<TargetFrameworks>MonoAndroid90;netstandard2.0;Xamarin.iOS10;</TargetFrameworks>
<!--Assembly and Namespace info -->
<RootNamespace>Company.Example.Controls</RootNamespace>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<AssemblyFileVersion>1.0.0.0</AssemblyFileVersion>
<Version>1.0.0.0</Version>
<NeutralLanguage>en</NeutralLanguage>
<!-- Helper to add defines-->
<DefineConstants>$(DefineConstants);</DefineConstants>
<!--Version of C# to use -->
<LangVersion>default</LangVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<!-- Define what happens on build and release -->
<PropertyGroup Condition=" '$(Configuration)'=='Debug' ">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)'=='Release' ">
<DebugType>pdbonly</DebugType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<!-- If we want a nuget package on build, add this -->
<!-- <GeneratePackageOnBuild>true</GeneratePackageOnBuild> -->
</PropertyGroup>
<ItemGroup>
<!-- This None is here so the conditionally included files show up in the Solution Explorer -->
<None Include="**\*.cs;**\*.xml;**\*.axml;**\*.png" Exclude="obj\**\*.*;bin\**\*.*;bin;obj" />
<!--NuGet packages for all platforms-->
<PackageReference Include="SkiaSharp" Version="1.68.0" />
<PackageReference Include="SkiaSharp.Views.Forms" Version="1.68.0" />
<PackageReference Include="Xamarin.Forms" Version="3.6.0.293080" />
<!--Project references for all platforms-->
<!-- <ProjectReference Include="..\..\..\Framework\Company.SomeLibrary.csproj" /> -->
<!--Update all .xaml files in shared -->
<EmbeddedResource Update="Shared\**\*.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<!--Compile all .xaml files in shared-->
<EmbeddedResource Update="Shared\**\*.xaml">
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
<!--Compile all .cs files in shared-->
<Compile Include="Shared\**\*.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
</ItemGroup>
<!--Do this exclusively for Android-->
<ItemGroup Condition=" '$(TargetFramework)' == 'MonoAndroid90' ">
<Compile Include="Platforms\Android\**\*.cs" />
<!-- We can reference assemblies... -->
<Reference Include="System.Data" />
<!-- We can also reference NuGet packages... -->
<PackageReference Include="FAB.XamarinAndroid" Version="1.6.4" />
<!-- If we have resources on Android, add these... -->
<!--
<AndroidResource Include="Resources\**\*.axml" />
<AndroidResource Include="Resources\**\*.xml" />
<AndroidResource Include="Resources\**\*.png" />
<Compile Include="Resources\Resource.designer.cs" />
-->
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'MonoAndroid90' ">
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
</PropertyGroup>
<!--Do this exclusively for iOS-->
<ItemGroup Condition=" '$(TargetFramework)' == 'Xamarin.iOS10' ">
<Reference Include="System.Data" />
<Compile Include="Platforms\iOS\**\*.cs" />
<!--<Copy SourceFiles="$(NuSpecPath)" DestinationFolder="$(PackageSource)\Resources"/>-->
<!--<Content Include="Resources\*.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>-->
</ItemGroup>
<ItemGroup>
<Folder Include="Platforms\Android\" />
<Folder Include="Platforms\iOS\" />
<Folder Include="Platforms\" />
<Folder Include="Shared\" />
<Folder Include="Resources\" />
</ItemGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment