Bug 58284 - Unable to add a reference to project (Targets are not the same or compatible)
Summary: Unable to add a reference to project (Targets are not the same or compatible)
Status: RESOLVED DUPLICATE of bug 52932
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-07-20 22:48 UTC by Derek Foulk
Modified: 2017-07-21 18:43 UTC (History)
2 users (show)

Tags: class library, pcl, profile
Is this bug a regression?: ---
Last known good build:

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 or GitHub 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 DUPLICATE of bug 52932

Description Derek Foulk 2017-07-20 22:48:42 UTC
Hey dudes,

I'm trying to add a reference to our Xamarin.Forms PCL (App) project. The project I'm trying to reference is a Xamarin.Forms Class Library.

Steps to reproduce:

1) Open VS2017 v15.2 (26430.16) in Windows 10
2) Create a new 'Cross Platform App (Xamarin)' project (Blank/PCL)
3) Create a new 'Class Library (Xamarin.Forms)' project (in the same solution)
4) Open the 'Cross Platform App (Xamarin)' project
5) Try to add a reference to the 'Class Library (Xamarin.Forms)'

You will be greeted by an alert that says:

***Unable to add a reference to project 'MyClassLibrary'. The targets of Portable Library project 'MyClassLibrary' are not the same or compatible with the targets of the current Portable Library project.
 
A Portable Library project's targets can be changed via the Library tab in the project's properties.***

This error is caused by the fact that the two PCLs are created using different profiles...

'Class Library (Xamarin.Forms)' uses Profile111

'Cross Platform App (Xamarin)' (Blank/PCL) uses Profile259

Of course, we are unable to add 'Windows Phone Silverlight 8' (Thus converting Profile111 => Profile259) so... Yeah! The 'Class Library (Xamarin.Forms)' project is completely useless in the current version of VS2017.

Are there any workarounds that don't involve [this](https://www.danrigby.com/2014/04/10/windowsphone81-pcl-xamarin-fix/)?

Thanks!
Comment 1 Derek Foulk 2017-07-20 23:04:58 UTC
"Just remove 'Windows Phone Silverlight 8' from the 'Cross Platform App (Xamarin)' (Blank/PCL) targets (converting it from Profile259 => Profile111)"... You can't because Microsoft has removed Windows Phone 8 targets from the 'Change Targets' window ([see this thread](https://developercommunity.visualstudio.com/content/problem/18198/pcl-change-targets-window-and-add-portable-class-l.html#comment-20133)).
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2017-07-21 00:05:46 UTC Comment hidden (obsolete)
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2017-07-21 00:08:15 UTC
Correcting a typo to add the word "example" in Comment 2 (I will accordingly mark that comment as obsolete):




## Quick preliminary non-engineering team note about possible workarounds

> Are there any workarounds that don't involve...

One option is to open the .csproj file in a text editor [1] and change the `TargetFrameworkProfile` property to match the other PCL projects in the solution.

[1] (For example you can right-click the project in the Solution Explorer, select Unload Project, right-click the project again, and select Edit Project.)




## Cross-referencing note for the Xamarin team

The mismatch in PCL profiles between the 2 template projects is filed in Bug 52932, and a candidate fix for that issue (so that newly created projects will match each other as expected) is currently targeted for the upcoming "Xamarin 15.4 release" previews.
Comment 4 Derek Foulk 2017-07-21 00:11:19 UTC
I can confirm that manually editing the .CSPROJ file (for the Class Library) fixes the issue:

-    <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
+    <TargetFrameworkProfile>Profile259</TargetFrameworkProfile>

I can now add the reference. Much appreciated!
Comment 5 Jimmy [MSFT] 2017-07-21 15:54:47 UTC
As Brendan pointed out, this is an issue with the templates in Visual Studio and it has been fixed in a future release. In that case, I will mark this as a duplicate. Thanks!

*** This bug has been marked as a duplicate of bug 52932 ***
Comment 6 Derek Foulk 2017-07-21 18:43:19 UTC
Oops! I didn't see bug 52932 during my pre-post search. I guess I didn't realize what was causing the issue when I posted the bug... My bad! Thanks guys!