{"action":"created","issue":{"url":"https://api.github.com/repos/NuGet/Home/issues/1625","labels_url":"https://api.github.com/repos/NuGet/Home/issues/1625/labels{/name}","comments_url":"https://api.github.com/repos/NuGet/Home/issues/1625/comments","events_url":"https://api.github.com/repos/NuGet/Home/issues/1625/events","html_url":"https://github.com/NuGet/Home/issues/1625","id":112817707,"number":1625,"title":"dotnet TFM and Portable Class Libraries appear incompatible","user":{"login":"tillig","id":1156571,"avatar_url":"https://avatars.githubusercontent.com/u/1156571?v=3","gravatar_id":"","url":"https://api.github.com/users/tillig","html_url":"https://github.com/tillig","followers_url":"https://api.github.com/users/tillig/followers","following_url":"https://api.github.com/users/tillig/following{/other_user}","gists_url":"https://api.github.com/users/tillig/gists{/gist_id}","starred_url":"https://api.github.com/users/tillig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillig/subscriptions","organizations_url":"https://api.github.com/users/tillig/orgs","repos_url":"https://api.github.com/users/tillig/repos","events_url":"https://api.github.com/users/tillig/events{/privacy}","received_events_url":"https://api.github.com/users/tillig/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/NuGet/Home/labels/Viewed","name":"Viewed","color":"f7c6c7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-10-22T14:41:13Z","updated_at":"2015-10-26T15:15:20Z","closed_at":"2015-10-23T00:55:51Z","body":"I'm unsure if this is a bug, but it's making life difficult so I figured I'd report it. ([My original blog entry about it is here.](http://www.paraesthesia.com/archive/2015/10/20/gotcha-with-dnx-dependency-resolution-dotnet-pcl/))\r\n\r\nI'm also not entirely sure if this is a `dnu` issue or a NuGet issue.\r\n\r\nWe recently released [Autofac 4.0.0-beta8-157](https://www.nuget.org/packages/Autofac/4.0.0-beta8-157) to NuGet to coincide with the DNX beta 8 release. As part of that update, we re-added the classic PCL target `.NETPortable,Version=v4.5,Profile=Profile259` (which is `portable-net45+dnxcore50+win+wpa81+wp80+MonoAndroid10+Xamarin.iOS10+MonoTouch10`) because older VS versions and some project types were having trouble finding a compatible version of Autofac 4.0.0 - they didn't rectify the `dotnet` target framework as a match.\r\n\r\nIn working on a beta 8 compatible version of [Autofac.Configuration](https://github.com/autofac/Autofac.Configuration), which targeted `dnx451`, `dotnet`, and `net45` in beta 7, I figured we could just update to start using Autofac 4.0.0-beta8-157.\r\n\r\nInstead, I started getting a lot of build errors when targeting the `dotnet` framework moniker.\r\n\r\n```\r\nBuilding Autofac.Configuration for .NETPlatform,Version=v5.0\r\n  Using Project dependency Autofac.Configuration 4.0.0-beta8-1\r\n    Source: E:\\dev\\opensource\\Autofac\\Autofac.Configuration\\src\\Autofac.Configuration\\project.json\r\n\r\n  Using Package dependency Autofac 4.0.0-beta8-157\r\n    Source: C:\\Users\\tillig\\.dnx\\packages\\Autofac\\4.0.0-beta8-157\r\n    File: lib\\dotnet\\Autofac.dll\r\n\r\n  Using Package dependency Microsoft.Framework.Configuration 1.0.0-beta8\r\n    Source: C:\\Users\\tillig\\.dnx\\packages\\Microsoft.Framework.Configuration\\1.0.0-beta8\r\n    File: lib\\dotnet\\Microsoft.Framework.Configuration.dll\r\n\r\n  Using Package dependency Microsoft.Framework.Configuration.Abstractions 1.0.0-beta8\r\n    Source: C:\\Users\\tillig\\.dnx\\packages\\Microsoft.Framework.Configuration.Abstractions\\1.0.0-beta8\r\n    File: lib\\dotnet\\Microsoft.Framework.Configuration.Abstractions.dll\r\n\r\n  Using Package dependency System.Collections 4.0.11-beta-23409\r\n    Source: C:\\Users\\tillig\\.dnx\\packages\\System.Collections\\4.0.11-beta-23409\r\n    File: ref\\dotnet\\System.Collections.dll\r\n\r\n  (...and some more package dependencies that got resolved, then...)\r\n\r\n  Unable to resolve dependency fx/System.Collections\r\n\r\n  Unable to resolve dependency fx/System.ComponentModel\r\n\r\n  Unable to resolve dependency fx/System.Core\r\n\r\n  (...and a lot more fx/* items unresolvable.)\r\n```\r\n\r\nThis was, at best, confusing. I mean, in the same target framework, I see these two things together:\r\n\r\n```\r\n  Using Package dependency System.Collections 4.0.11-beta-23409\r\n    Source: C:\\Users\\tillig\\.dnx\\packages\\System.Collections\\4.0.11-beta-23409\r\n    File: ref\\dotnet\\System.Collections.dll\r\n\r\n  Unable to resolve dependency fx/System.Collections\r\n```\r\n\r\nSo it _found_ System.Collections, but it _didn't find_ System.Collections? Running the `dnu list --details` command, I saw this:\r\n\r\n```\r\n[Target framework .NETPlatform,Version=v5.0 (dotnet)]\r\n\r\nFramework references:\r\n  fx/System.Collections  - Unresolved\r\n    by Package: Autofac 4.0.0-beta8-157\r\n\r\n  fx/System.ComponentModel  - Unresolved\r\n    by Package: Autofac 4.0.0-beta8-157\r\n\r\n  (...and a bunch more of these...)\r\n\r\n\r\nPackage references:\r\n* Autofac 4.0.0-beta8-157\r\n    by Project: Autofac.Configuration 4.0.0-beta8-1\r\n\r\n* Microsoft.Framework.Configuration 1.0.0-beta8\r\n    by Project: Autofac.Configuration 4.0.0-beta8-1\r\n\r\n  Microsoft.Framework.Configuration.Abstractions 1.0.0-beta8\r\n    by Package: Microsoft.Framework.Configuration 1.0.0-beta8\r\n\r\n  System.Collections 4.0.11-beta-23409\r\n    by Package: Autofac 4.0.0-beta8-157...\r\n    by Project: Autofac.Configuration 4.0.0-beta8-1\r\n\r\n  (...and so on.)\r\n```\r\n\r\nWhat I see is that Autofac 4.0.0-beta8-157 needs _both_ the framework assembly _and_ the dependency package for `System.Collections` which seems weird.\r\n\r\nLooking in the generated `.nuspec` file for the updated core Autofac, I see:\r\n\r\n```xml\r\n<?xml version=\"1.0\"?>\r\n<package xmlns=\"http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd\">\r\n  <metadata>\r\n    <!-- ... -->\r\n    <dependencies>\r\n      <group targetFramework=\"DNX4.5.1\" />\r\n      <group targetFramework=\".NETPlatform5.0\">\r\n        <dependency id=\"System.Collections\" version=\"4.0.11-beta-23409\" />\r\n        <dependency id=\"System.Collections.Concurrent\" version=\"4.0.11-beta-23409\" />\r\n        <!-- ... -->\r\n      </group>\r\n      <group targetFramework=\".NETFramework4.5\" />\r\n      <group targetFramework=\".NETCore4.5\" />\r\n      <group targetFramework=\".NETPortable4.5-Profile259\" />\r\n    </dependencies>\r\n    <frameworkAssemblies>\r\n      <!-- ... -->\r\n      <frameworkAssembly assemblyName=\"System.Collections\" targetFramework=\".NETPortable4.5-Profile259\" />\r\n      <frameworkAssembly assemblyName=\"System.ComponentModel\" targetFramework=\".NETPortable4.5-Profile259\" />\r\n      <frameworkAssembly assemblyName=\"System.Core\" targetFramework=\".NETPortable4.5-Profile259\" />\r\n      <frameworkAssembly assemblyName=\"System.Diagnostics.Contracts\" targetFramework=\".NETPortable4.5-Profile259\" />\r\n      <frameworkAssembly assemblyName=\"System.Diagnostics.Debug\" targetFramework=\".NETPortable4.5-Profile259\" />\r\n      <frameworkAssembly assemblyName=\"System.Diagnostics.Tools\" targetFramework=\".NETPortable4.5-Profile259\" />\r\n      <!-- ... -->\r\n    </frameworkAssemblies>\r\n  </metadata>\r\n</package>\r\n```\r\n\r\n**The list of failed `fx/*` dependencies is exactly the same as the list of `frameworkAssembly` references that target `.NETPortable4.5-Profile259` in the `.nuspec`.**\r\n\r\nBy removing the `dotnet` target framework moniker from Autofac.Configuration and compiling for _specific targets_, everything resolves correctly.\r\n\r\nAgain, I'm not sure if this is the desired behavior, but it seems if you have a library that takes a dependency on something that targets _both_ `dotnet` and a PCL profile, you suddenly can't support `dotnet` unless you _also_ support the PCL profile.\r\n\r\nIf you'd like to try this and see it in action, check out [the Autofac.Configuration repo at `14c10b5bf6`](https://github.com/autofac/Autofac.Configuration/tree/14c10b5bf6216b1bdfb1f5414105161eeba06f9f) and run the `build.ps1` build script.\r\n\r\n**If this is a `dnu` issue, let me know so I can post the issue over on the aspnet repo.**"},"comment":{"url":"https://api.github.com/repos/NuGet/Home/issues/comments/151169890","html_url":"https://github.com/NuGet/Home/issues/1625#issuecomment-151169890","issue_url":"https://api.github.com/repos/NuGet/Home/issues/1625","id":151169890,"user":{"login":"tillig","id":1156571,"avatar_url":"https://avatars.githubusercontent.com/u/1156571?v=3","gravatar_id":"","url":"https://api.github.com/users/tillig","html_url":"https://github.com/tillig","followers_url":"https://api.github.com/users/tillig/followers","following_url":"https://api.github.com/users/tillig/following{/other_user}","gists_url":"https://api.github.com/users/tillig/gists{/gist_id}","starred_url":"https://api.github.com/users/tillig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillig/subscriptions","organizations_url":"https://api.github.com/users/tillig/orgs","repos_url":"https://api.github.com/users/tillig/repos","events_url":"https://api.github.com/users/tillig/events{/privacy}","received_events_url":"https://api.github.com/users/tillig/received_events","type":"User","site_admin":false},"created_at":"2015-10-26T15:15:20Z","updated_at":"2015-10-26T15:15:20Z","body":"From a level-setting standpoint: Autofac is an inversion-of-control container for .NET. It's like a tool or framework library. It's not, itself, an _application_.\r\n\r\nThe reason I say that is that I think there may be a misunderstanding or a slight miscommunication, which could be just me. Autofac _is used by people on these platforms_ but Autofac proper _does not, itself_, \"use a platform.\" So when you ask if \"I'm using WinRT,\" the answer is, \"No, **I'm** not using WinRT, but the **people that consume Autofac** are.\" This same answer goes for the other platforms.\r\n\r\nWe chose the **Autofac core** (ie `Autofac.dll`) frameworks by looking at profile 259 - the profile we supported before NuGet 3 and the new TFMs - and trying to approximate it with the new TFMs. The problem we ran into was that if we _only_ used `dnx451`, `dotnet`, `net45`, `netcore45` that VS 2013 and some other project types would fail to find a compatible Autofac despite actually being compatible. By adding the profile 259 back in, we got compatibility with the older VS and project types that weren't previously finding them. For example, profile 259 allowed us to be compatible with Xamarin.\r\n\r\nWhen _only_ targeting the portable profile, we had challenges with newer project types finding a compatible Autofac. This combination of profiles seemed to be the magic combination that allowed us to continue supporting the platforms we had supported before the new TFMs were introduced.\r\n\r\nI've tried several combinations of the new TFMs in conjunction with the portable profile 259 for core Autofac and if I remove any of the new TFMs, I've generally found a project type that stops finding a compatible Autofac. I don't have comprehensive doc on which project types or target frameworks stop working for each of the TFMs. I should probably have kept better records on that, but I didn't and it's too late now. If it's not _hurting_ anything, I'd just as soon leave it; but if you think the extra targets are contributing to the problem I'm seeing, I can definitely go back and start documenting more specifically what I'm seeing.\r\n\r\n**Building core Autofac (`Autofac.dll`) works great.**. Core Autofac has its own build, its own repo, etc. It's a separate thing. The problem is in building Autofac.Configuration.\r\n\r\n**The Autofac.Configuration project is an extension on Autofac.** Autofac.Configuration (ie, `Autofac.Configuration.dll`) is also a tool/framework library. It allows you to use a configuration file to specify dependencies that get registered into your Autofac IoC container.\r\n\r\nThere is _one build_ of Autofac.Configuration. It takes a dependency on core Autofac and on Microsoft.Framework.Configuration.\r\n\r\n**Autofac.Configuration does not target PCL profile 259.** Core Autofac does. Autofac.Configuration does not target profile 259 because Microsoft.Framework.Configuration is not seen as compatible with profile 259.\r\n\r\nMy goal is to allow Autofac.Configuration to be compatible with the subset of frameworks that both core Autofac and Microsoft.Framework.Configuration support. I would like to achieve maximum compatibility.\r\n\r\nThis is where I'm failing: I can't get Autofac.Configuration to support UWP despite all of its dependencies supporting that framework. What that means is that I can't offer configuration support to people using the Autofac IoC container on that platform, and I'd really, really like to. I would love to know how to make that happen."}}