{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/cli/issues/4047","repository_url":"https://api.github.com/repos/dotnet/cli","labels_url":"https://api.github.com/repos/dotnet/cli/issues/4047/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/cli/issues/4047/comments","events_url":"https://api.github.com/repos/dotnet/cli/issues/4047/events","html_url":"https://github.com/dotnet/cli/issues/4047","id":171150304,"number":4047,"title":"preserveCompilationContext causing failed references for runtime compilation","user":{"login":"Antaris","id":255906,"avatar_url":"https://avatars.githubusercontent.com/u/255906?v=3","gravatar_id":"","url":"https://api.github.com/users/Antaris","html_url":"https://github.com/Antaris","followers_url":"https://api.github.com/users/Antaris/followers","following_url":"https://api.github.com/users/Antaris/following{/other_user}","gists_url":"https://api.github.com/users/Antaris/gists{/gist_id}","starred_url":"https://api.github.com/users/Antaris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Antaris/subscriptions","organizations_url":"https://api.github.com/users/Antaris/orgs","repos_url":"https://api.github.com/users/Antaris/repos","events_url":"https://api.github.com/users/Antaris/events{/privacy}","received_events_url":"https://api.github.com/users/Antaris/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-15T11:03:43Z","updated_at":"2016-11-12T06:57:11Z","closed_at":"2016-11-12T06:57:11Z","body":"Hi,\n\nI am having some issues performing an upgrade from RC2 and RTM. I have a set of libraries deployed to an internal NuGet feed, they have `preserveCompilationContext` set to true. This is mostly because we don't have any clear indication as to whether we are supposed to include that in all projects, or just host projects? `preserveCompilationContext` generates a `.deps.json` file describing the dependency tree for that library.\n\nNow, in my host MVC application, the `MetadataReferenceFeatureProvider` is generating metadata references for the Roslyn-based Razor compiler. \n\nSo, given an example dependency `My.Application.Abstractions`, what I am finding, is that for those assemblies that exist in packages, it is trying to load the `DependencyContext` for each one. Because of the `preserveCompilationContext` setting in the `project.json` project file of the source dependency, there is an entry in the `.deps.json` file:\n\n```\n{\n  // .deps.json shorted for brevity\n  \"libraries\": {\n    \"My.Application.Abstractions/1.0.0-master\": {\n      \"type\": \"project\",\n      \"serviceable\": false,\n      \"sha512\": \"\"\n    }\n  }\n}\n```\n\nNow, when iterating through the `DependencyContext.CompileLibraries` property to resolve the reference paths, because the `type` key is set to `project`, it means the `PackageCacheCompilationAssemblyResolver` is skipped (https://github.com/dotnet/cli/blob/rel/1.0.0/src/Microsoft.Extensions.DependencyModel/Resolution/PackageCacheCompilationAssemblyResolver.cs#L39) and in the `AppBaseCompilationAssemblyResolver` (https://github.com/dotnet/cli/blob/rel/1.0.0/src/Microsoft.Extensions.DependencyModel/Resolution/AppBaseCompilationAssemblyResolver.cs#L93) the only directory specified is the application output `./bin/debug/netcoreapp1.0` which doesn't contain the package assembly. Additionally the `PackageCompilationAssemblyResolver` returns `false` because the compilation library is of type `project`. This has a the net result of failing to obtain a reference at all, giving this lovely exception:\n\n`Can not find compilation library location for package`My.Application.Abstractions'\n\nSo I have a couple of questions:\n1. When using `preserveCompilationContext` in a library, should it be generating `project` as the `type` value?\n2. Should we be using `preserveCompilationContext` at all, what are the exact scenarios this _should_ be used and for what types of projects?\n3. How do I solve my current issue.\n\nIt's difficult to try and generate a working example that I can upload, but if I can, I'll update this issue.\n\nI've cross-posted this over at aspnet/MVC (https://github.com/aspnet/Mvc/issues/5141) as I am unsure as to where this belongs.\n\n**Environment**\n\n```\n.NET Command Line Tools (1.0.0-preview2-003121)\n\nProduct Information:\n Version:            1.0.0-preview2-003121\n Commit SHA-1 hash:  1e9d529bc5\n\nRuntime Environment:\n OS Name:     Windows\n OS Version:  10.0.14393\n OS Platform: Windows\n RID:         win10-x64\n```\n"},"comment":{"url":"https://api.github.com/repos/dotnet/cli/issues/comments/260106181","html_url":"https://github.com/dotnet/cli/issues/4047#issuecomment-260106181","issue_url":"https://api.github.com/repos/dotnet/cli/issues/4047","id":260106181,"user":{"login":"piotrpMSFT","id":2379589,"avatar_url":"https://avatars.githubusercontent.com/u/2379589?v=3","gravatar_id":"","url":"https://api.github.com/users/piotrpMSFT","html_url":"https://github.com/piotrpMSFT","followers_url":"https://api.github.com/users/piotrpMSFT/followers","following_url":"https://api.github.com/users/piotrpMSFT/following{/other_user}","gists_url":"https://api.github.com/users/piotrpMSFT/gists{/gist_id}","starred_url":"https://api.github.com/users/piotrpMSFT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/piotrpMSFT/subscriptions","organizations_url":"https://api.github.com/users/piotrpMSFT/orgs","repos_url":"https://api.github.com/users/piotrpMSFT/repos","events_url":"https://api.github.com/users/piotrpMSFT/events{/privacy}","received_events_url":"https://api.github.com/users/piotrpMSFT/received_events","type":"User","site_admin":false},"created_at":"2016-11-12T06:57:11Z","updated_at":"2016-11-12T06:57:11Z","body":"I'm glad the issue was resolved. If there are lingering problems here we'll need to tackle them as they become concrete. "}}
{"actor":{"display_login":"piotrpMSFT"}}