Bug 9276 - Unable to add a reference to a portable library project
Summary: Unable to add a reference to a portable library project
Status: RESOLVED DOWNSTREAM
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 1.0.x
Hardware: PC Windows
: Highest enhancement
Target Milestone: 1.3.x
Assignee: Jose Miguel Torres
URL:
: 10345 ()
Depends on:
Blocks:
 
Reported: 2013-01-04 13:46 UTC by Eric Maupin
Modified: 2013-10-28 16:35 UTC (History)
7 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
PCL Reference Test (41.36 KB, application/zip)
2013-08-06 12:33 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DOWNSTREAM

Description Eric Maupin 2013-01-04 13:46:42 UTC
I created a new iOS project, added a portable library project to the solution and tried to add a reference to it from the iOS project.

---------------------------
Microsoft Visual Studio
---------------------------
Unable to add a reference to project 'Newtonsoft.Json.Portable'. The current project does not support references to Portable Library projects.
---------------------------
OK   
---------------------------
Comment 1 Eric Maupin 2013-01-06 21:50:43 UTC
Just FYI, MFA has the same issue.
Comment 2 Jose Miguel Torres 2013-01-07 03:37:15 UTC
This is the explanation of Michael Hutchinson about PCL compatibility:

<<PCL is a fairly well understood problem, the problem is there are lots
of little details we'd need to fix up to make it fully supported. As
well as installing XML files into the SupportedFrameworks directories
of each PCL profile to mark them as compatible with MT/MfA, we need to
audit the MT/MfA classlibs for all of the type forwarding attributes
to make them PCL compatible. At this point it would work on Windows
for both VS2010, VS 2012, and MD 3.0.7+ (yes, MD supports PCL, Jeff's
been working on that on and off with some pointers from me and it's
pretty complete). >>
Comment 3 Jose Miguel Torres 2013-01-25 04:10:42 UTC
Right now, PCL is not 100% supported. We may deploy XML file inside SupportedFrameworks and it will be partially supported (see ...  http://www.screencast.com/t/PqmVJ2oPm) but we have to make some modifications in class libs as Michael points out.
Comment 4 PJ 2013-02-17 20:44:05 UTC
*** Bug 10345 has been marked as a duplicate of this bug. ***
Comment 5 Jose Miguel Torres 2013-06-04 11:04:08 UTC
Will be ready when we land PCL.
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2013-08-06 12:32:42 UTC
A user has recently reported that this does not work in VS2012, Xamarin.iOS 1.3.250.

## Steps to reproduce

1. Open attached PCL Reference Test solution.
2. Edit references for "PCLProjectReferenceTest", and try to add a reference to "PortableClassLibrary".


## Result

"Unable to add a reference to project 'PortableClassLibrary'. The current project does not support references to Portable Library projects."

But adding a reference to "PortableClassLibrary" works on the Mac using Xamarin Studio, and if you add the reference to the PCL project on the Mac and then copy the solution back to the PC, Visual Studio will successfully build, deploy, and debug it (with build warnings about not supporting references to PCL projects).
Comment 7 Brendan Zagaeski (Xamarin Team, assistant) 2013-08-06 12:33:30 UTC
Created attachment 4553 [details]
PCL Reference Test
Comment 8 Olivier Dahan 2013-10-26 10:18:53 UTC
Is there any news ? I have updated with xamarin.android 4.8.3 and existing solution under VS is now showing the "PCL not supported" warning in android project.
This was working with preceding xamarin.droid version...

Is there a fix ?
Comment 9 softlion 2013-10-28 14:01:26 UTC
+1 same problem with both 4.8.3 and 4.10.0, on VS2012 and VS2013.
Comment 10 Brendan Zagaeski (Xamarin Team, assistant) 2013-10-28 14:15:49 UTC
@Olivier and @softlion:
This problem arises when Visual Studio cannot confirm that Xamarin projects support PCL profiles. Visual Studio uses XML files to determine this compatibility. To resolve this, you can add appropriate XML files following Stuart Lodge's examples [1] to the various "SupportedFrameworks" folders. For example, for Profile104, you would copy the XML files into:

> C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\Profile\Profile104\SupportedFrameworks

[1] http://slodge.blogspot.com/2013/04/my-current-pcl-setup-in-visual-studio.html


Once full Xamarin PCL support is released, these XML files will be added to the appropriate SupportedFrameworks folders automatically during Xamarin installation.

See also Bug #10345
Comment 11 Brendan Zagaeski (Xamarin Team, assistant) 2013-10-28 14:18:49 UTC
Ah, never mind about Bug #10345. It's a private Xamarin bug, but not to worry. It just contains another brief wording of the same explanation.
Comment 12 softlion 2013-10-28 15:34:01 UTC
@brendan: doing this breaks nugets which then disallow adding any portable nuget package to any pcl projet.

This is worst than the problem.
Comment 13 Olivier Dahan 2013-10-28 15:57:58 UTC
@Brendan

That's ok, I knew this XML trick in profile 104, I already had this file (one for monodroid and one for monotouch, so 2 files in reality)... It is just that the XML  files has been suppressed. I finally found that my XML file disappeared and this was causing the problem.
 
XML suppression occurred after I updated Xamarin.
But as I also installed VS2013 around the same day, this can be a VS problem not a Xamarin one.
You will notice that in this case installing VS2013 can suppress profiles used by VS2012. Must be confirmed. At least one of this update is the culprit...

Well, now my VS2012 is ok and I can open Xamarin projects. But I can't no more work with cross-platforms projects including for example Android and WinRT : Android/Xamarin is working only in VS2012 and with Windows 8.1 WinRT apps can only be done using VS 2013 !

I know Xamarin is working on VS2013 integration, I just hope this is a high priority task for the team because for cross-plateform it is a super big problem.

Thanks for your help.
Olivier.
Comment 14 Brendan Zagaeski (Xamarin Team, assistant) 2013-10-28 16:35:48 UTC
Thanks for the extra information from you both! Very much appreciated.

@softlion:
The ideal solution for the NuGet problem is for NuGet to fix up its logic. See http://nuget.codeplex.com/workitem/2926, and particularly mhutch's comment. Xamarin would definitely like to have this working, so depending how things go on the NuGet side, there might be another prettier workaround in the future.

For the time being, one workaround would be to go back and remove the Xamarin SupportedFrameworks XML files, and then either:

1. Add a reference to the PCL project by hand-editing the .csproj MSBuild XML file. That is, add something like this to the app project:
> <ItemGroup>
>   <ProjectReference Include="..\PortableClassLibrary1\PortableClassLibrary1.csproj">
>     <Project>{6a87ccf5-99da-4d71-a440-b40cd3c3afcd}</Project>
>     <Name>PortableClassLibrary1</Name>
>   </ProjectReference>
> </ItemGroup>

2. Reference the compiled DLL from the PCL project instead of the project itself.

As far as I've seen, Visual Studio only complains about _adding_ the PCL project as a reference. Once the reference is included, VS still shows a warning icon, but it compiles the app project successfully anyway.