-
Notifications
You must be signed in to change notification settings - Fork 258
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
Impossible to target Xamarin.Mac .NET 4.5 Framework #2662
Comments
can you please find the right Xamarin contact here? |
@chamons should be the Xamarin contact for this. |
There are three distinct problems which need resolving:
Repro over at https://github.com/ghuntley/repros/tree/master/nuget/Issue2662 and https://github.com/ghuntley/repros/blob/master/nuget/Issue2662/Issue2662.nuspec |
Hello everyone. I'm the Xamarin.Mac lead from Xamarin. 👋 Sorry I didn't get the summons before. The breakdown from @mteper is pretty solid from what I can tell. We have things documented here: https://developer.xamarin.com/guides/mac/advanced_topics/target-framework/ My detailed knowledge of nuget is lacking, so I apologies in advance for my ignorance. A bit of a history lesson here will help explain how we got into the situation we are in: When we created the Unified, we originally (in XM 1.12) only had the "Mobile" target framework for preview. However, a significant number of people were consuming a a lot of nuget packages, which knew nothing about "xamarinmac". This was a world of pain, and unacceptable. XM 4.5 was our last minute "solution". It lies, at least a bit, about what it is, so that we can consume many of those packages, which actually just work under the hood. However, if you "know" about XM 4.5 and want to provide special builds, say because your "desktop" build depends on Windows specific version, there is no good way to sub them in. Is there a way (my end or your end?) where we can say something like: if there is a xamarinmac45 build use that, if not fall back to the "normal desktop" build we're already using? |
@joelverhagen. We talked about this a bit internally. Adding Joel, He can take a look at this issue and help identify what exactly is needed to fix this issue. |
@ghuntley, could you give me a little more background on your repro? I have not worked with Xamarin Studio very much so it's not clear to me how to reproduce the issue. Also -- another silly question -- what is the "XM45" TFM? |
@joelverhagen when you open the solution in Xamarin Studio, right-click on the project and select Options. Then, switch to "General" tab under "Build". You will see the framework target options I referred to in the initial case description.
|
@joelverhagen Xamarin internally calls "Xamarin.Mac .NET 4.5 Framework" by the codename Inside that repro you will find two dummy applications:
Additionally there are three dummy libraries.
The end goal is to make XM45 recognised by NuGet and design how/if/when a XM45 library is installed depending on the scenarios above into the two applications. |
Got it. It seems to me that you would like to add a new Adding a TFM to NuGet is relatively straightforward. The list of frameworks that NuGet knows about is in this file, so this is where the work should be started: This file also contains all of the framework equivalencies, compatibilities, subsets, etc.
Precedence is an angle that must be very well unit tested to avoid regressions as new TFMs are added. |
I have knowledge in this area so I could work on the implementation, probably within the next couple weeks. You are also free to work on a PR which NuGet team can review. I understand these Xamarin TFMs as abstract terms but I am pretty ignorant about when or why they are used. Let's nail down some details. Clarifying questions for points already made:
New questions:
Note that NuGet has a generic rule that all frameworks support themselves when the package framework version is less than or equal to the project framework version. For example, |
We are looking at renaming the "XM 4.5" target framework already. I agree that it is a terrible name. I'm ok with the internal name not matching that. :) I am honestly unsure on all of the existing nuget identifiers. I think how it works is:
I believe your assertions (i, ii, iii) are correct. net45 is it's own thing. xamarinmac/xamarinmac20 should be it's own thing (it is limited like iOS). xamarinmacnet45 (or whatever we call it) should fall back to net45 . On your questions:
|
So My assertion "iii" above was:
I want to make sure these details are exactly right 😄 |
I'll spell it out in non-nuget first, since I'm 99% sure on that, then do the translation: Xamarin.Mac Mobile (/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/) - Really only is safe pulling it builds just built for it. It is a rather limited subset of the BCL. If you pull in net45 here, then you often get brokenness. Xamarin.Mac XM 4.5 (Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/) - This is the guy that pretends to be a "normal desktop" assembly. This is where we'd love the "if there is a special build for it, use that, else fall back to standard net45" behavior. I believe mobile = xamarinmac and xm45 = xamarinmacnet45 and thus: xamarinmac just supports itself and does not fall back (this is the current behavior, right?) Does that sound reasonable? Clear as mud? |
What about XM45 falling back to |
Correct.
Yes, NuGet does not know about the
@mteper and @chamons, this is your call as you know the details of these compatibilities at runtime. If |
Hmm. That is a hard one @mteper Mobile is almost, but not a complete subset of XM 4.5. That is not a scenario that we've considered / tested / know even works. However, it would be rather useful, as the insights use was shows. Let me think and get back to this thread later today... |
@chamons wrote,
FWIW, we have it working in production for |
So in terms of just number of assemblies, I believe XM 4.5 is an actual superset of Mobile: https://github.com/xamarin/xamarin-macios/blob/master/builds/Makefile#L102 However, we build the mono class library very differently: https://github.com/mono/mono/blob/master/mcs/build/profiles/xammac.make where Mobile is built, well like the "mobile" iOS profile and XM 45 is built like desktop, except for places where that is unavoidable. I rather like the idea of XM 4.5 falling back on Mobile, as it really makes the life of nuget devs easy if they want to support XM and they can fit inside mobile. Let me poke a few people here and see if there is some disaster I'm not considering. |
To give you an idea of the sort of changes I plan on making for this new TFM, take a look at my feature branch here: I will not put this as a PR until I've heard back from you @chamons about |
I can't think of a reason why this isn't a great idea, and my colleagues at work (who also don't know nuget super well) can't come up with a counterexample either. 👍 When would this change reach a nuget near me? I'd like to tweet / post on our forums to let Xamarin.Mac users know about the change. |
How do you normally consume NuGet? Do you use the .NET CLI experience? NuGet.exe? |
Yep. That's the problem with lying. Sometimes you get caught. However, there are a huge number of nuget packages out there that don't know about XM at all. If we don't lie, we can't use any of them. The XM45 target framework was\is an imperfect solution to an unhappy problem. I'm happy to hear better solutions, doubly so if they are backwards compatible. :) |
I do not have enough context with nuget to understand the question enough to answer it safely. What XM45 ships in almost all cases is what mono builds in their "normal" build. For example for System.dll in XM45 we just use: "System.dll.sources" (https://github.com/mono/mono/blob/master/mcs/class/System/xammac_net_4_5_System.dll.sources) I have no idea what that maps to in nuget land. |
In the project.json world, this problem is addressed using I am not familiar with the project system you are working with. Could project.json be used? |
(edited to clarify my wording 😓) |
All Xamarin projects (that I know of) are the standard msbuild project format processed by xbuild. |
AFAIK, project.json isn't yet supported by Xamarin Studio...in the stable channel. I've heard that it is available in the alpha channel. You should be able to use project.json with any project type though for nuget references, I blogged about how. |
@chamons the term "project.json" is overloaded. It can be used with MSBuild, in which case it's just a replacement for packages.config, not the build system. As Oren mentioned, we support this in the alpha channel. I don't see how this can work in the form proposed - the 4.5 frameworks for XM don't have a TFM of their own for NuGet to match on, and we can't add one without breaking the ability to reference 4.5 library projects. Solving this is going to be difficult. |
Is this still being pursued? This has been a painful problem. |
I am having a similar issue. When I have a Xamarin.Mac .NET 4.5 app install my nuget package it uses the net45 targetFramework or the uap10.0 if listed in the nuspec. If I don't remove the uap10.0 group my nuget package won't install at all. When I don’t comment the UWP section the error I get is this: Package 'Microsoft.NETCore.Jit.1.0.3' does not exist in folder '/Users/xavierr/svn/XamarinNew/packages' However the log shows it was retrieved. |
This has continued to be a really painful issue for us. Surprised it has not been fixed after all this time. Anyway to get this prioritized? |
I dont see this going any where. There was a open PR for over an year but then no further movement so we had to close that PR. I'm not sure what NuGet can do here except this scenario is supported for new I'm not sure we're going to do much about |
- `Xamarin.Mac.NET` is both `Xamarin.Mac,Version=v2.0` (preferred) AND `.NETFramework,Version=v4.5` - Related to - NuGet/Home#2662 - NuGet#562 - NuGet/NuGet2#47
Reopened this with NuGet/NuGet.Client#2572 |
+1 This is going to be a problem for anyone trying to use Xamarin.Mac from a console app per https://docs.microsoft.com/en-us/xamarin/mac/app-fundamentals/console. |
Situation
Xamarin.Mac projects can be set up to target one of the following Frameworks:
Xamarin.Mac Mobile Framework, defined as:
Xamarin.Mac .NET 4.5 Framework, which is defined as:
The list of supported assemblies is here: http://developer.xamarin.com/guides/mac/advanced_topics/assemblies/
Unsupported Framework, e.g.
Mono / .NET 4.5
, but the UI has this to say:Problem
Only one of the three targets above (mobile) maps to the
xamarinmac
TFM. When a project set up to target either of the other two framework targets adds or updates a NuGet package that contains binaries for "xamarinmac", it instead picks up the "net45" ones. This is problematic for libraries like ReactiveUI, Splat, Xamarin.Insights, etc. The onus then falls on the developer to manually update path references in their .csproj files, which causes undue friction and errors, especially on larger teams.Here's the corresponding Xamarin issue: https://bugzilla.xamarin.com/show_bug.cgi?id=21338
Now that Xamarin is part of Microsoft, can we please get this pain addressed?
The text was updated successfully, but these errors were encountered: