Project Linker for Xamarin Studio

When working in C# projects that target multi plataforms and need to have a high code reuse ration, like those that must run on iOS, Android, Windows Phone and any other desktop platform where .NET might run (Windows itself, Linux and Mac) it is common to face a problem: how to share code between the different projects, while maintaining your sanity?

PCL (Portable Class Libraries) is a possible solution, however it is a fairly new feature even in Visual Studio (it is fully supported starting in the 2012 version), and Xamarin Studio / MonoDevelop still have some heavy work to do. Also, PCL imposes some restrictions on what you are allowed to do as well.

One common approach is to have a “Core” project that targets the full .NET framework, and a series of “Linked” projects with compiler flags specific to each platform. This is very well described at the page “Sharing Code Options” at Xamarin’s website. However, do that by hand is not productive and error prone. Visual Studio users can make use of a extension, but how about Xamarin Studio?

Wait no more, now it is possible to do project linking in Xamarin Studio / MonoDevelop as well, with the Project Linker extension I created.

This addin was developed in order to automatically create and maintain links from a source project to a set of target projects, in order to make code sharing between different plataforms a more friendly task. It is based on the Visual Studio Project Linker extension.

The main reason behind the development of this addin was that I was working on a project that targets multiple plataforms using the great MvvmCross library, including iOS, Android, Windows, Mac and Linux, and PCL support was very lacky on Xamarin Studio, and even on Visual Studio 2012 it had its problems. Also, PCL programming imposes some restrictions that I found harder to workaround than using a third party plugin to do the file linking between the projects.

Features

  • Automatically replicates “new”, “delete” and “rename” operations from the source to the target projects
  • Allows to perform a manual synchronization, which is useful if you use both Visual Studio and Xamarin Studio or if someone else does not have the plugin and changes the project
You can install the extension directly from within Xamarin Studio, with the “Addins manager” tool. More instructions and information you can find at http://rafaelsteil.github.io/monodevelop-project-linker/

2 thoughts on “Project Linker for Xamarin Studio

  1. Awesome! Goes a long way making the cross platform hell much easier to bear. Now, we just need to be able to link directly to the ‘core’ project and not require the copies for each platform. If only msbuild/xbuild was used for everything, it might be possible!

  2. It is a very good point Curtis, and makes me wonder about it. ln the Java land it is much more common to relly on Ant or other similar tools to build the projects, but I quite don’t see this approach on .NET projects.

    I am taking a good look at your Eto.Forms project (hell of a project, btw) and I saw that you have a script to execute msbuild outside the IDE, which is an approach I will consider.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


five + = 14

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>