Fix for Creating PCLs in Visual Studio That Target Windows Phone 8.1 and Xamarin
Trouble in Paradise
With BUILD over and the Visual Studio Update 2 RC released, many of us are playing with the new Windows Phone 8.1 bits.
However, if you're using Xamarin in Visual Studio and you've tried to create a new (or update an existing) Portable Class Library that targets both the new Windows Phone 8.1 application type and Xamarin iOS/Android, you may have encountered a problem:
At this moment, Xamarin is aware of the issue and a fix will be coming in an updated release of the Xamarin tools for Visual Studio, but if you're impatient like me and want/need to use the bits RIGHT NOW, there is in fact a workaround...
A New Hope
So what do we need to do? Turns out the workaround is pretty straight forward.
Open up the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78\SupportedFrameworks
folder (changing the drive letter accordingly) and select Xamarin.Android.xml
and Xamarin.iOS.xml
.
If you only have Xamarin for iOS or Xamarin for Android installed, you may only see one of these 2 files and that's perfectly fine.
Now we're going to copy the file(s) to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile259\SupportedFrameworks
. You may be prompted for administrator rights to do this, just click ok.
So, why did we choose Profile 259 anyway?
Well, prior to Visual Studio 2013 Update 2, Xamarin's best supported (and favorite) profile was PCL profile 78.
PCL Profile 259 is Profile 78 + Windows Phone 8.1 (and the "new profile 78") which should give us the highest amount of compatibility.
At this point close Visual Studio (if it was still open) and then launch it again.
Now if we select .NET Framework 4.5, Windows 8, Windows Phone Silverlight 8, Windows Phone 8.1, Xamarin.Android, and/or Xamarin.iOS everything should work...
Epilogue
If you can't use Profile 259 because you need to support different platform targets, this fix works for other profile numbers as well, though Xamarin compatibility may be dimished as the PCL Profile may support some functionality that one or more of the Xamarin platforms can't (ex. dynamic).
A good example would be if you also needed to target Silverlight 5. You would copy the two xml files into the .NETPortable\v4.0\Profile\Profile344
folder (This is also a very good profile for Xamarin development).
Credits
This fix comes courtesy of Oren Novotny, so if it helps you, be sure to thank (and follow) him!