-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Can't reference a PCL project from an ASP.NET core project. #1356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's currently not supported but will be in RC2. |
Similar situation on my end except with just a UWP app and several ASP.NET Core WebAPI services - wanted PCLs between them with RC1. In case someone was curious in the latest RC1 (1.0.0-rc1-update2) it's still not functional. |
Just wanted to point out that I'm on RC2 and didn't get it to work yet. |
Yep, can confirm, no go with RC2. |
@MihaMarkic I've actually gotten this working myself, in RC2... it was much-required for one of the projects I'm working on. Are you getting any specific errors when trying to reference it? Can you elaborate on exactly what's happening with it? |
Create a .net core libarary project A, a PCL (.net 4.5 + asp.net core 1.0) B. The following projects are not supported as references :
A:
B:
Perhaps PCLs can be referenced from only asp.net core projects, but not from .net core console/libraries? |
Just a quick update: it doesn't work for me with 1.0 RTM either. @Rdefreitas if you could elaborate how you did it (or answer my SO question directly) I would be grateful. |
Does not work with Update3 + 1.0.0 preview2 tooling on 1.0.0 EDIT: Got it CLOSER with netstandard1.5 and 4.6.2 preview:
Core DLL side:
And 4.6.2 project imported the core dll reference BUT I CANT SEE ANY CORE DLL OBJECTS?!? |
What's the current status? I'm experiencing the same issue trying to reference PCL from aspnet core application. Is there another way to share code between aspnet core and xamarin application? |
I got around the problem until the issue is fixed by making the referenced project .netcore instead of PCL. But you need to reference the dll itself instead of the project. And you'll have to build the referenced project when you make changes. |
@kewur Thanks for the workaround. But what about Xamarin application? Won't there be troubles with referencing core assembly? |
I was able to run it on the emulator, never tried on the device though. |
@kewur I have just created .NET Core .dll project and referenced it from both aspnet and Xamarin.Android applications. I haven't run them, but build succeeded. Maybe that's workaround I've been looking for. Anyway, thanks for your help. |
I am sorry to say that I have been trying to get this to work and "no luck". I have projects I need to share between ASP.Net Core 1.0 RTM and Xamarin and it is trouble all the way. Problem #1: I cannot reference the PCL project from the .net core project. I added the compat layer and the "imports" and the reference dialog box works, but the solution does not compile. It seems like the compiler does not "see" the PCL project. It cannot resolve Problem #2: If I convert the PCL project to Standard Library, then Xamarin Forms PCL has problems saying that the v4.5 (Xam PCL) is not compatible with the v5.0 (std lib). I am lost... Problem #3: If I try to convert the entire Xamarin project to Standard Library then the problem is that many dependencies are not ported to .Net Core / Std Libs yet. For example, many of the Xamarin libs and even MvvmLight. I talked to both, James Montemagno and Laurent Buignion, and both have confirmed that there is clear a plan to port, but we are not there yet. As Montemagno said, "Standard Libraries are still new". Anyhow, a real mess... I still wonder if it is a tech. problem, or a tooling problem... I don't know where to log issues or give input... ;) Thanks... |
That's what I'm having right now.
But there's more. So, to share code base between ASP.NET Core and Xamarin we need both projects reference .NET Standart targeted library. And use ReSharper 2016.2 EAP 2 or higher or not to use ReSharper at all. Hope somebody will find this helpful. |
@prilutskiy It seems like we are in rather similar situations. That is good in the terms of consistency. BTW, is is thread closed ? Is anyone from MS reading this? Should we be posting somewehere elese ? |
@cspaniard I'm not sure. Let's try reaching someone. @glennc Hi Glenn, what do you think on this point? |
@prilutskiy The reason I think It might be closed is this: So I wonder if were are "screaming" in the desert... hahahaha cheers |
This thread is still opened. @davidfowl any update on it ? thanks, |
It would be helpful if we could all work off the same sample projects. I can reproduce some of the many problems described in this thread. The move back to msbuild should make most of this work more seamlessly than today.
/cc @abpiskunov |
@davidfowl I agree with all your points. Nuget: 3.5.0.1484 (is this the latest ?, VS says nothing about a newer update available) My solution still does not compile from within VS. All I am doing is a .Net Core console app with imports trying to reference a PCL. Any ideas ? I am missing something ? Can we confirm is a VS/Tooling issue ? |
I specifically called this out saying .NET Core applications don't work with PCL projects in the IDE. Intellisense isn't working. That's likely a bug because packages work fine. Convert the PCL to a .NET Standard project. |
@davidfowl I know, I was trying to support your point. I was with you... I was trying to say you were right. I cannot convert the PCL to a .NET Standard project because it does not work with Xamarin if converted. Some kind of v4.5 vs v5.0 collision I don't understand very well. I can reproduce it if you want. I really appreciate all your help with this. |
Can you clarify this point? What fails? Do you have a minimal project you can push to github to show the issue? |
@davidfowl I will work on it and I will put it together... I can get it done by tomorrow... |
@davidfowl Hi... uploaded the minimal project to github that shows the issue. A Xamarin Forms PCL project trying to reference a Standard Library project. This is the issue itself: Here is the github link: Once gain... thank you for looking into it. |
Hey @cspaniard, I was able to reference the Standard Library from the Xamarin PCL, the trick was to unreference all nugget packages, retarget to Standard Library and then re-add the nuget references. The repro is easy, just target a Xamarin PCL to standard library and try to add the reference on the xamarin uwp project. Any thoughts on that @davidfowl thanks a lot, |
What is a Xamarin PCL?
What is a Xamarin UWP project? Is it just a UWP project? Are all projects using /cc @emgarten |
Hi @gugavaro, If I understand your process correctly, you converted your Xamarin PCL project to Standard Library. Is that correct ? If that is the case, I run into all sorts of trouble since a lot of the libs/pkgs I use are not converted to Std Libs yet. I contacted James Montemagno about this and he mentioned that the commitment is to move to the Std Libs, but since they are kind of new, they are not there yet. Lots of work ;) |
Hi @davidfowl, Xamarin PCL is the PCL version of a Xamarin project. Today Xamarin can be used in 2 modes:
I am using the PCL version of Xamarin Forms. BTW, where you able to clone the project OK ? |
Xamarin PCL is a normal PCL. Nothing special, same goes for Xamarin UWP. |
Ok, I got it to work across all the platforms, have not tested yet running code, but at least it is compiling. Here are the Steps: 1 - Created a PCL If you select any higher version of the .Net Standard (i.e.: 1.3 and above) the UWP and Windows projects will not be able to reference the PCL, it seems they are only compatible with .Net Standard up to 1.2 version. The problem is that I am seeing a lot of nugget packages already targeting higher versions, for example here:
There is a table with the compatibility support between platforms and versions: This table helped me understand the issues. Could one of your guys verify it and I will close this issue, @cspaniard @MihaMarkic @prilutskiy @jcapellman ? thanks a lot everyone here. |
Hi @gugavaro, I have not being able to replicate your example. However, it might be my fault. From my perspective, I am trying to find an equilibrium between 2 issues here.
After a closer reading of your directions, I am not sure which one (if any) you are trying to work around. Both need attention and resolution.
As you can see I changed to Profile7, but with Profile111, it doesn't work either. Right now the tooling issue is in MS' hands and I would like to continue working with all of you until we can identify the 2nd issue. Can you explain what is your starting point and where you are trying to get ? How were you able to point to StdLib v1.3 and still add the reference from within VS ? Let´s stay in touch people ;) |
Hi @cspaniard I am able to call a PCL from asp.net core with no problem and even the tooling is working fine for me. For the second issue, I see you are using Xamarin Forms and if you look on the nugget Xamarin forms info it does not support standard library, however it does support a normal .net PCL, in this case why you need to have a netstandard pcl ? See if those steps help you:
let me know if so far it works for you. If now you are also working with Xamarin Forms.
it should work. Thanks, |
Hi @gugavaro You are "the man"... Kudos to you... it works just like you said it would... Just let me write a few notes about your comments/questions and confirm your points:
Samething here once I followed your directions... The tooling is still broken and autocompletion is not there. However, it does compile from within VS.
The latest Xamarin is supposed to be able to reference Standard Libs. Actually James Montemagno wrote a blog about it. I sent him a tweet about migrating to StandardLibs and he mentioned that the idea is to get there, but there are a lot of libs to port.
I don't really, as long as I can run my code in all the different environments. As you can see, I need my libs to run on Asp.Net Core, Desktop WPF, Console and Xamarin. Now, with your directions, I can. I changed all my PCL projects (including Xamarin) to follow your directions and now they compile and work great. All I can say is thank you... Cheers, |
Hi @cspaniard, I am glad you got it working.
Let me know if you have any other question and I will be happy to try to help you. take care, |
So if I understand correctly, it compiles and runs but we are missing IntelliSense? ben |
I have 3 projects:
I would like to share my model project between my Xamarin UI and my ASP.NET core, so I can have a single project that holds the Models.
I can reference my PCL project from my Xamarin project without any problem, but when I try to reference the PCL from the asp.net core, the reference window does not give me any warning when I select the PCL project, but the reference does not gets added after a select and click okay.
Any hints on how to solve this issue?
thanks,
Gustavo.
The text was updated successfully, but these errors were encountered: