Bug 22856 - PCL projects won't load
Summary: PCL projects won't load
Status: CLOSED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: General ()
Version: 3.6
Hardware: PC Windows
: High critical
Target Milestone: 3.6
Assignee: vsx
URL:
Depends on:
Blocks:
 
Reported: 2014-09-11 02:47 UTC by Miha Markic
Modified: 2015-07-29 11:14 UTC (History)
12 users (show)

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


Attachments
Patched Xamarin.iOS.xml (167 bytes, patch)
2014-09-12 07:56 UTC, Jose Gallardo
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:
CLOSED FIXED

Description Miha Markic 2014-09-11 02:47:45 UTC
Since the latest beta update (3.6.something) of 11th sept. Visual Studio 2013 U3 won't open PCL projects anymore, at least most of them.
It'd say "The project is incompatible with the current edition of Visual Studio" in solution explorer.

Repro: Create a new solution with a PCL class library, i.e. Profile7. Everything is fine. Save and reopen - bum won't load it.
Comment 1 softlion 2014-09-11 03:52:50 UTC
It's the alpha version
Comment 2 Miha Markic 2014-09-11 03:54:09 UTC
For me it is beta as I am on beta channel. Or did alpha infiltrate beta channel somehow?
Comment 3 softlion 2014-09-11 05:29:14 UTC
it has been moved to beta also this morning :)
Comment 4 Jamie 2014-09-11 06:07:30 UTC
Same problem, Profile78
Comment 5 Sunil Kumar 2014-09-11 08:00:04 UTC
I have tried to reproduced this issue and I am also getting the same issue. When I create PCL project save it and reopen it again then it shows message "The project is incompatible with the current edition of Visual Studio" in solution explorer for Library project.

Screencast: http://www.screencast.com/t/fM564zeHGKd
IDE Log: https://gist.github.com/sunil360/f1d95e414da307330c5f

Environment info: 
VS 2013 update 2
Xamarin   3.6.198.0 (9a4fd01eaf32adf894f8bd1d687455dcb905f427)
Xamarin.Android   4.16.0.14 (62e09eb09d3a9056653f1ef497de30b53bf04f47)
Xamarin.iOS   7.9.21.0 (1ed3187e662f3b5a059fa6df4d7c480046290ea3)
Comment 6 Jose Gallardo 2014-09-11 12:44:31 UTC
We're already looking into this issue.
Comment 7 Jose Gallardo 2014-09-11 23:17:47 UTC
The root cause of the issue is that we were using the same DisplayName for both: Xamarin.iOS.xml and Xamarin.iOS.Unified.xml in every portable profile.

i.e. You can see this case in "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78\SupportedFrameworks" where both xml files are using the same DisplayName="Xamarin.iOS". This was making VS to mixup the referenced assemblies and failing to load the project with an "Incompatible" error.

The manual workaround is to replace the Xamarin.iOS.xml DisplayName="Xamarin.iOS (Classic)", at least in the profile you're using, but you might need to do that change for every profile.

We already have a fix, which should be available soon.
Comment 9 Jamie 2014-09-12 04:14:44 UTC
@Jose I've updated the Xamarin.iOS.xml files (for all profiles) and I'm still seeing the same issue?
Comment 10 softlion 2014-09-12 05:21:34 UTC
It fixes the issue for me
Comment 11 softlion 2014-09-12 05:22:01 UTC
Make sure you're using .net 4.5 ?
Comment 12 softlion 2014-09-12 05:24:59 UTC
Ok it fixes this issue, but it still have a show stopper issue (compilation error) when implemeting an interface containing a generic type.
Comment 13 softlion 2014-09-12 05:26:59 UTC
oups no sorry it didn't fixed it.
Comment 14 Jamie 2014-09-12 05:33:03 UTC
I am using .NET 4.5
Comment 15 greg 2014-09-12 05:35:35 UTC
fix doesn't work for me either
Comment 16 softlion 2014-09-12 06:00:52 UTC
I works when you remove all xamarin.ios.unified.xml files. But then you can no more reference a PCL project from an ios project.
Comment 17 softlion 2014-09-12 06:03:04 UTC
Unless you have done so before.
Comment 18 softlion 2014-09-12 06:10:15 UTC
Ok it works but ios projects won't compile. It does not find generics used by methods in a C# interfaces from PCL.
Comment 19 softlion 2014-09-12 07:48:40 UTC
Ok i managed to get it work. Here's how:

go to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\

search and delete all files called "Xamarin.iOS.xml"

Restart Visual Studio

It fixes all issues EXCEPT my bug 22812 (can not implement an interface declared in a PCL if the interface contains method with a generic parameter: won't compile).
Comment 20 Jose Gallardo 2014-09-12 07:56:14 UTC
Created attachment 8026 [details]
Patched Xamarin.iOS.xml
Comment 21 Jose Gallardo 2014-09-12 07:58:10 UTC
@Softlion: Removing all Xamarin.iOS.Unified.xml files from the Profiles means we're not longer compatible with those profiles. Hence it makes sense you cannot reference PCLs anymore, or if you already have some referenced, your project doesn't build.

@Jamie, @krahenbuhl: I also had to restart Visual Studio, and my changes were in all the profiles (for v4.0,v4.5 and v.4.6). This will be done by our installer once the fixed version is public.

This is how I implemented the workaround in my machine:
1. Close all Visual Studio instances.
2. Move all the Profile folders you don't use to a Backup folder (so you can restore it later), I recommend you to group them by .Net version (v4.0, v.4.5 and v4.6). Leave just the ones you use, like i.e. v.4.5/Profile78
3. Replace Xamarin.iOS.xml in the remaining profiles (i.e.Profile78) with the attached one (In comment 20).

That said, We'll investigate the build error to see if there is anything else needed.

Thanks
Comment 22 Sunil Kumar 2014-09-12 11:55:44 UTC
We have checked this issue and now this does not exist. When I create PCL project, save and close it and reopen it again then it reloads successfully.

Screencast: http://screencast.com/t/666QFdX53H

Environment info:
Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.50938

Xamarin   3.6.206.0 (b0fc63894f19ecfc80ad83f515319a6348fc605a)

We are getting error on creating PCL project and I have field Bug 22938 for the same.

Hence I am closing this issue.
Comment 23 Jamie 2014-09-12 13:26:44 UTC
@Jose thanks. I only replaced the .NET 4.5 files - there's many more files in .NET 4!
Comment 24 Jamie 2014-09-12 13:31:19 UTC
Now I have errors about attributes in the PCLs not being attributes and missing references to System.ObjectModel and System.Runtime...
Comment 25 Jose Gallardo 2014-09-12 19:59:58 UTC
A quick update, to clarify the current status: There are actually two issues in the Alpha/Beta 3.6.197 versions related to this scenario:

1) PCL projects cannot be open (This one is fixed, and soon will be public, this is the fix + workaround mentioned on this thread).

2) Build errors due to missing references on PCLs (this is a different issue, and cannot be seen until you can actually reload the PCL). This issue is currently under investigation.

We'll post here updates about the progress on the second issue.
Comment 26 Jose Gallardo 2014-09-12 20:36:37 UTC
We found what's causing the second issue. It was the iOS Build targets file that was not including facade assemblies in the build process. The workaround is to patch the target file, typically located on:

C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets

You can close Visual Studio, copy that file into a different location, edit it replacing the "ResolveReferenceDependsOn" element with the following: 

		<ResolveReferencesDependsOn>
			_SeparateAppExtensionReferences;
			$(ResolveReferencesDependsOn);
			ImplicitlyExpandDesignTimeFacades
		</ResolveReferencesDependsOn>

and then copying it back replacing the one in the MSBuild\Xamarin\iOS folder.

That should avoid the missing references error.

We'll continue working on the official fix for this second issue which should be available soon.

Thanks
Comment 27 Jamie 2014-09-13 04:55:16 UTC
Thanks @Jose, builds and deploys now (although doesn't debug) :-)
Comment 28 Jamie 2014-09-13 06:34:22 UTC
It fixed the referencing errors I had before, and deploys and runs on the simulator but now this is present when deploying / building for the device:

C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(384,3): warning : The dependency 'System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of the assembly 'Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' was not found. Please review the project's references.
Comment 32 greg 2014-09-15 08:02:31 UTC
Thanks Jose - the two workarounds work fine for me
Comment 33 greg 2014-09-15 08:06:21 UTC
Actually it works fine for existing projects however, when updating nuget packages the errors reoccurs (for example after updating Xamarin.Forms -> the old version is removed but new version cannot be installed - it works if they are changed manually in the .csproj file).
Comment 34 softlion 2014-09-16 13:04:07 UTC
Hello,
this is NOT fixed in 3.6.223.0.

The reference errors is still there. If the fix is applied and the solution reopened, all ios projects displayed are "incompatible" and an error is displayed.

  <entry>
    <record>796</record>
    <time>2014/09/16 15:30:02.595</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>SetSite failed for package [MonoTouchPackage]</description>
    <guid>{77875FA9-01E7-4FEA-8E77-DFE942355CA1}</guid>
    <hr>80131500</hr>
    <errorinfo>Activation error occured while trying to get instance of type IBuildHost, key ""</errorinfo>
  </entry>
Comment 35 softlion 2014-09-16 13:06:14 UTC
To fix, i deleted all Xamarin.iOS.Unified.xml files in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5
Comment 36 softlion 2014-09-16 13:18:57 UTC
Well no, that fix it one time only.
Comment 37 greg 2014-09-18 07:28:20 UTC
softlion: It works for me - the latest update fixed the Xamarin.iOS files, no need to touch them anymore.
 
I still had the unrelated reference bug for which the fix is editing: 

C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets

You can close Visual Studio, copy that file into a different location, edit it
replacing the "ResolveReferenceDependsOn" element with the following: 

        <ResolveReferencesDependsOn>
            _SeparateAppExtensionReferences;
            $(ResolveReferencesDependsOn);
            ImplicitlyExpandDesignTimeFacades
        </ResolveReferencesDependsOn>


Hope it helps
Comment 38 Dan Rigby 2014-09-18 14:27:32 UTC
The NuGet team has released an alpha version of 2.8.3 which includes support for the new Xamarin.iOS.Unified profile: https://nuget.codeplex.com/releases/view/133091

This should resolve error messages about:
- Cannot install a Nuget Package on any of the compatible Portable Class Library profiles
- Create a Xamarin.Forms application or library shows a NuGet Package error

This avoids needing to remove all of the Xamarin.iOS.Unified.xml files.
Comment 39 softlion 2014-09-22 06:04:27 UTC
@greg: version 3.7.126.0 has all fixes, but all Android/ios projects fail to load. Going back to stable.
Comment 40 Maikel 2015-03-05 10:54:16 UTC
Removing the Xamarin.iOS.Unified.xml files seems to fix the issue only once. 

New profile xml files are created when upgrading Xamarin to a newer version. After upgrading to Xamarin to 3.9.344.0, the Xamarin.iOS.Unified.xml files are created with still contain the display name that cause the PCL loading problem:

<Framework DisplayName="Xamarin.iOS" Identifier="Xamarin.iOS" Profile="*" MinimumVersion="1.0" MaximumVersion="*" />

When will there be a permanent fix for this bug?
Comment 41 Jose Gallardo 2015-03-05 17:28:35 UTC
Hi Maikel, 

The issue you're facing sounds like an old NuGet Packaged Manager in Visual Studio.

According to Xamarin VS 3.9 Release Notes (http://developer.xamarin.com/releases/vs/xamarin.vs_3/xamarin.vs_3.9/):

Update to latest NuGet Package Manager (2.8.3+) is required
Updating to the latest version of  Microsoft NuGet Package Manager, which is compatible with Xamarin.iOS Unified API, is required. It can be updated from the Visual Studio Extension Manager.
More information is available in the following Visual Studio Gallery's links:

VS 2013: https://visualstudiogallery.msdn.microsoft.com/4ec1526c-4a8c-4a84-b702-b21a8f5293ca
VS 2010, VS 2012: https://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c

Hope that helps!
Comment 42 Maikel 2015-03-06 05:57:46 UTC
Hello Jose, 
Forgot to mention that I did upgrade NuGet to v2.8.3 after upgrading Xamarin to  v3.9. After upgrading NuGet restarting VS2013 my PCL's did not load. 

Anyhow, I cannot understand why Xamarin did not fix the root cause, that is changing the DisplayName in the XML file.

Thanks,
Maikel
Comment 43 Jose Gallardo 2015-03-06 06:33:31 UTC
Hi Maikel,

The display name issue was fixed months ago. I'll verify it just in case it's a regression, and confirm.
Perhaps you still have the old xmls for some reason?

I'll comment once I can confirm.

Thanks for the clarification!

-j
Comment 44 Jose Gallardo 2015-03-06 08:46:01 UTC
I can confirm the fix stills in place, and the Xamarin.iOS.Unified.xml and Xamarin.iOS.xml files we ship do have the right DisplayName.

For instance, after installing the latest stable (v3.9.344), Xamarin.iOS.xml contains:
<Framework DisplayName="Xamarin.iOS (Classic)" Identifier="MonoTouch" Profile="*" MinimumVersion="1.0" MaximumVersion="*" />

This might be some setup issue on your machine or in the installer itself.
Please try installing the msi from this URL http://download.xamarin.com/XamarinforVisualStudio/Windows/Xamarin.VisualStudio_3.9.344.msi which should match the current stable, and let me know if you continue seeing the wrong DisplayName.

Also, the full path of the xml file you're seeing the issue would also help, as if it's wrong just in some of the profiles but it's good in the other profiles.

Thanks!
Comment 45 Maikel 2015-03-06 09:12:02 UTC
Thanks Jose for confirming this. I checked the xml files on my system and can explain exactly what the problem is with my Xamarin installation. 

The installer of version 3.9.344 did, in my case, not overwrite existing Xamarin.iOS.xml files with the fix. New Xamarin.iOS.Unified.xml files were created correctly during install (because these files did not exist). 

So there seems to be an issue with overwriting the xml profiles. I suspect this is not related to fs write permissions because new xml files were created correctly.
Comment 46 Maikel 2015-03-06 09:23:38 UTC
In addition, i can inform you that sub folders of these folders still contain old xml files after the upgrade:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable
\v4.0\Profile\Profile[nr]\SupportedFrameworks
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile[nr]\SupportedFrameworks
Comment 47 Daniel Cazzulino 2015-07-29 11:14:36 UTC
Closing since the error isn't happening anymore.