Converting Xamarin Libraries to SDK Style & Multi-Targeted Projects


If you are like me you may have a lot of standard Xamarin.iOS and Xamarin.Android libraries sitting around. They aren’t plugins, but they do extend a single platform with custom functionality and controls. Wouldn’t it be great if you could update them to the new SDK Style projects which use Package References, auto-NuGet packaging, and load WAY faster?!?!? It is all crazy simple to do just like converting old PCLs to .NET Standard. If you are setting up CI this is going to be a huge time saver as you can set it up in VSTS in minutes (blog coming this week).

Unload that Project

First things first, we need to get at that raw .csproj madness. Right click on the project and click Unload Project. Then right click again and select Edit *.csproj:

Delete Everything!

That is right! Delete it all because we don’t need it at all!

Replace it with my base project information. It is a bit verbose but based on the type of library you are creating there are some special things that you may want to include such as Android resources.

Note: I like to only compile items that end in .shared.cs, .ios.cs, or .android.cs to keep it tidy, but you can easily change what you compile into your library in the project structure.

Right click and re-load the project!


Spice it up

Now you can go in and any NuGets you may need with the PackageReference node in the ItemGroup of your choosing. Additionally, you can also turn on Multi-Targeting to generate both an iOS and Android (or whatever else like UWP and netstandard) by change TargetFramework to TargetFrameworks and specifying more frameworks.


NuGet that Library

What is great about the SDK style projects is that you don’t need a .nuspec at all for your NuGet and it can

Report Story

Leave Your Comment